W开发者_开发百科ould recursive=-1
help in case of find("list")
in cakephp. I mean any performance benefit
With the default
$this->Post->find('list');
CakePHP make this query:
SELECT `Post`.`id`, `Post`.`name` FROM `posts` AS `Post` WHERE 1 = 1
No recursive query, so changing that command will not improve the query
No, recursive=-1 will not help full in case of $this->Model->find('list').
If you want to find('all') or find('first') , then it will be more use full.
eg. User , VatInfo , VatInfoLog are three models then
1) recursive=-1
$this->VatInfo->find('all') Will return only VatInfo table data.
2) recursive=0
$this->VatInfo->find('all') Will return $belongsTo User And VatInfo 2 tables data.
3) recursive=1
$this->VatInfo->find('all') Will return $belongsTo User ,$hasMany VatInfoLog And VatInfo 3 tables data.
Try it!
In debug mode Cake shows you the running time of each query. Try both ways and see if anything changes. My guess is no, since it's only taking data from one table anyway for list
queries.
精彩评论