cow*_*wls 0 php cakephp containable
我正在尝试从2级深度的模型中检索特定字段.我使用容器行为,但没有正确检索底层.
下面是代码:
$this->Review->Behaviors->attach('Containable');
$latestReviews = $this->Review->find('all', array(
'contain' => array(
'Business' => array(
'fields' => array('Business.name'),
'BusinessType' => array(
'fields' => array('BusinessType.url')
)
),
),
'fields' => array('overall'),
));
Run Code Online (Sandbox Code Playgroud)
它返回的数组:
array(
(int) 0 => array(
'Review' => array(
'overall' => '2'
),
'Business' => array(
'name' => 'Business Name',
'business_type_id' => '1',
'id' => '2012'
)
))
Run Code Online (Sandbox Code Playgroud)
但是,不是给我业务类型ID,而是希望它返回BusinessType url字段.
任何人都可以看到我错在哪里?我确定这与CakePHP文档一致.
| 归档时间: |
|
| 查看次数: |
1360 次 |
| 最近记录: |