2017-01-02 58 views
1

添加条件树形列表自定义查找我使用TreeBehavior使用自定义查找树形列表自定义查找如何在CakePHP中3

$this->Categories->find('treeList',['spacer' => '__']); 

现在生成树状结构如何添加一些条件像"isactive" =>true。我检查过的文档只有3个参数。无法找到状态PARAM提前

回答

2

这是少了“定制”取景器,更内置了一个

感谢,因为它附带CakePHP的核心。

这就是说,条件可以加入相同的方式与任何其他测距仪,即,或者经由传递给find()方法的第二个参数的conditions选项,或者通过查询构建器where()方法。从文档

报价:

一旦你开始查询您可以使用Query Builder接口 构建更复杂的查询,添加附加条件,限制或 包括使用流利协会接口。

// In a controller or table method. 
$query = $articles->find('all') 
    ->where(['Articles.created >' => new DateTime('-10 days')]) 
    ->contain(['Comments', 'Authors']) 
    ->limit(10); 

您还可以提供许多常用选项find()。这可以帮助 与测试,有更少的方法来模拟:

// In a controller or table method. 
$query = $articles->find('all', [ 
    'conditions' => ['Articles.created >' => new DateTime('-10 days')], 
    'contain' => ['Authors', 'Comments'], 
    'limit' => 10 
]); 

Cookbook > Database Access & ORM > Retrieving Data & Results Sets > Using Finders to Load Data