开发者

Find list in cakephp

开发者 https://www.devze.com 2023-01-19 15:25 出处:网络
W开发者_开发百科ould recursive=-1 help in case of find(\"list\") in cakephp. I mean any performance benefitWith the default

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消