I have this problem with mongodb using cakephp. I don't know how to find a record with its sub-array.
I have this structure in mongodb
id:"xxx",
profile:[
{
profile_pic:"xxx",
firstname:"xxx",
lastname:"xxx",
slug:"xxx"
}
]
I pass on the slug variable in the controller and I want to get the corresponding record with its slug. I use this code:
$profile = $this->User->find('first', array('first', array('conditions' => array('User.profile.slug' => $this->request['slug']))));
But this code is not working.
Aiyoh,
I had the wrong query in my profile. Should be:
$profile = $this->User->find('first', array('conditions' => array('profile.slug' => $this->request['slug'])));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.