2012-12-13 16 views
0

CakePHP的模型是否有可能使CakePHP的模型與相關的一些具體情況: 如:與條件

var $belongsTo = array(
    'Parent' => array(
     'className' => 'Category', 
     'foreignKey' => 'parent_id', 
     'dependent' => true 
    ) 
); 

我想在哪裏場parent_id0上述關係。請給出一些關於如何做到這一點的概述?

回答

2

您可以像關於查找一樣在關係中添加條件。

var $belongsTo = array(
    'Parent' => array(
     'className' => 'Category', 
     'foreignKey' => 'parent_id', 
     'dependent' => true, 
     'conditions' => array(
      ... 
     ) 
    ) 
); 
+0

它的返回一個空數組的其他領域...任何方式不顯示該數組的條件匹配 – user1871640