繁体   English   中英

如何使用mongodb在cakephp中找到子数组

[英]How to find a sub array in cakephp with mongodb

我在使用Cakephp的mongodb遇到此问题。 我不知道如何用其子数组查找记录。

我在mongodb中有这个结构

id:"xxx",
profile:[
{
    profile_pic:"xxx",
    firstname:"xxx",
    lastname:"xxx",
    slug:"xxx"
}

]

我在控制器中传递slug变量,并希望获得带有该slug的相应记录。 我使用以下代码:

$profile = $this->User->find('first', array('first', array('conditions' => array('User.profile.slug' => $this->request['slug']))));

但是此代码不起作用。

爱瑜

我的个人资料中的查询错误。 应该:

$profile = $this->User->find('first', array('conditions' => array('profile.slug' => $this->request['slug'])));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM