find('list')
进行查找,$params
中的'fields'
的值有所不同,这个时候定义的是结果集的索引(key),值(value)和组(group):
如果使用find('neighbors')
进行查找,$params
中的'field'
表示用来分析的字段,
'value'
则用来定义查找相邻数据(neighbor)时使用的值。注意
'field'
和'value'
只在find('neighbors')
时有效,在find('all’)
中是不使用的。
1
// 比如有1-10的id,想要取得上一个(1)和下一个(3)的数据。
2
$this->Post->id = 2;
3
$one = $this->Post->find('neighbors');
4
// 使用不同的字段查找相邻数据。
5
$two = $this->Post->find('neighbors', array('field'=>'Post.title', 'value'=>$data['Post']['title']));
6![](//pubimage.360doc.com/wz/default.gif)
为了提供对以前版本的兼容,find也可以接收下面的参数形式:
find(string $conditions, array $fields, string $order, int $recursive)
联系客服