天道酬勤,学无止境

cakephp-2.x

CakePHP 2.x GROUP BY within Containable

I am going nuts trying to find a good solution, either using the set::extract() or something. I want to add a GROUP BY within my containable: $params = array( 'conditions'=>array( 'Project.id'=>$ProjectId ), 'contain'=>array( //Gets the User Who owns the Project 'User'=>$user, 'Bid'=>array( //The User Who owns the Bid 'User'=>$user ), 'ProjectType', 'Os', 'Comment'=>array( 'To'=>$user, 'From'=>$user, 'group'=>"Comment.from_id" ), ), ); //debug($params); return $this->find('first',$params); I do not want to hack to get around this issue - is there an easier way to do this?

2021-06-24 05:19:37    分类:问答    php   cakephp   lamp   cakephp-2.x

在 cakephp 中使用回调方法解密和加密(Decrypt and Encrypt using CallBack Methods in cakephp)

问题 我想使用回调方法在值存储在我的数据库中之前对其进行加密,并在将其显示回应用程序之前对其进行解密。 我使用了文档中提供的示例之一。 在我的core.php我放置了以下内容: Configure::write('Security.cipherCriptKey','su0HKssPmdbwgK6LdQLqzp0YmyaTI7zO'); 在我的模型中,我使用了两种方法: beforeSave() public function beforeSave($options = array()) { $value=$this->data['Internship']['encryptedindb']; $encrypted = Security::encrypt($value, Configure::read('Security.cipherCriptKey')); $this->data['Internship']['encryptedindb'] = $encrypted; return true; } afterFind() public function afterFind($results, $primary = false) { foreach ($results as $key => $val) { if(isset($val['Internship'][

2021-06-23 11:25:47    分类:技术分享    php   cakephp   encryption   cakephp-2.x

CakePHP: How can I use a “HAVING” operation when building queries with find method?

I'm trying to use the "HAVING" clause in a SQL query using the CakePHP paginate() method. After some searching around it looks like this can't be achieved through Cake's paginate()/find() methods. The code I have looks something like this: $this->paginate = array( 'fields' => $fields, 'conditions' => $conditions, 'recursive' => 1, 'limit' => 10, 'order' => $order, 'group' => 'Venue.id'); One of the $fields is an alias "distance". I want to add a query for when distance < 25 (e.g. HAVING distance < 25). I have seen two workarounds so far, unfortunately neither suit my needs. The two I've seen

2021-05-17 16:47:31    分类:问答    mysql   cakephp   cakephp-2.x

Best way to upgrade a Cakephp project from Cakephp 2.6.2 to 3.8

I have been tasked with upgrading a legacy system from Cakephp2.6.2 to Cakephp3.8. Obviously the 2 are drastically different but is there a simple way of getting the old project to work with the new cake version? Or could anyone steer me in the right direction for the best way to do this?

2021-05-12 03:13:57    分类:问答    cakephp   migration   cakephp-3.x   cakephp-2.x

Decrypt and Encrypt using CallBack Methods in cakephp

I want to use the Callbacks methods to encrypt a value before it gets stored in my database and decrypt it before showing it back in the application. I used one of the examples provided in the documentation. In my core.php I put the following : Configure::write('Security.cipherCriptKey','su0HKssPmdbwgK6LdQLqzp0YmyaTI7zO'); In my Model, I used two methods: beforeSave() public function beforeSave($options = array()) { $value=$this->data['Internship']['encryptedindb']; $encrypted = Security::encrypt($value, Configure::read('Security.cipherCriptKey')); $this->data['Internship']['encryptedindb'] =

2021-05-11 16:16:23    分类:问答    php   cakephp   encryption   cakephp-2.x