php中CakePHP框架如何使用?
2024-08-01
来源:知网教育
作为主流的基于MVC架构的php框架,cakephp可谓非常耀眼了,不仅是第一个进入市场的框架,也是现在最好用的框架之一,随着时间的不停流逝,性能也不断的提升
1、$uses来声明
public $uses = array("Question", "Answer");
2、转换成对象
public $actsAs = array('Bean');
3、cakephp 查询
$conditions = array(); $conditions['or'] = array( array('BuddyRelationship.user_id'=>$userId, 'BuddyRelationship.buddy_user_id'=>$buddyUserId), array('BuddyRelationship.user_id'=>$buddyUserId, 'BuddyRelationship.buddy_user_id'=>$userId) ); $conditions['and'] = array('BuddyRelationship.status'=>self::Accepted, 'BuddyRelationship.deleted'=>self::Undeleted); $buddyCount = $this->find('count', compact('conditions'));
4、输出内容
$creditModel = ClassRegistry::init("Credit"); $conditions['and'] = array('Credit.amount <>'=>0); $conditions['and'] = array("User.id" => $uid); $credit = $creditModel->find('first', array('conditions'=>$conditions));
以上就是对于cakephp使用方式了,大家现在都应该清楚掌握了吧,好啦,感兴趣的小伙伴多多尝试下哦~
推荐操作系统:windows7系统、PHP5.6、DELL G3电脑