【发布时间】:2014-08-05 16:52:18
【问题描述】:
我在代理和类别这两个模型之间有一个 HABTM 关系。我已按照此处的说明进行操作: http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
我已经设置了表格,创建了 FK 等。为了测试是否正在检索类别以在代理上进行查找查询,我输入了以下调试代码:
debug($this->AgentsCategories->find('all', array(
'order' => array('Agent.name', 'Agent.address'),
'conditions' => array('Agent.id' => '59')
)));
结果数组:
array(
(int) 0 => array(
'Agent' => array(
'id' => '59',
'name' => 'MUTUAL UNDERWRITERS',
'address' => 'Waipahu Branch
94-615 Kupuohi St #102
Waipahu, HI 96797',
'telephone' => '808-688-2222',
'fax' => '808-688-0769',
'email' => null,
'website' => 'http://www.mutualunderwriters.com',
'island' => '1',
'modified' => '2014-04-16 15:56:46'
)
)
)
仅显示 Agents 表中的信息,不显示agents.id 是 FK 的类别表中的类别。根据说明,我希望得到类似以下示例的内容:
Array
(
[Recipe] => Array
(
[id] => 2745
[name] => Chocolate Frosted Sugar Bombs
[created] => 2007-05-01 10:31:01
[user_id] => 2346
)
[Ingredient] => Array
(
[0] => Array
(
[id] => 123
[name] => Chocolate
)
[1] => Array
(
[id] => 124
[name] => Sugar
)
[2] => Array
(
[id] => 125
[name] => Bombs
)
)
)
我做错了什么和/或我应该如何调试它?谢谢!
【问题讨论】:
-
显示您的代理模型代码
标签: php mysql sql cakephp has-and-belongs-to-many