aWebDeveloper
aWebDeveloper

Reputation: 38432

Find list in cakephp

Would recursive=-1 help in case of find("list") in cakephp. I mean any performance benefit

Upvotes: 0

Views: 1035

Answers (3)

Chandrakant Ganji
Chandrakant Ganji

Reputation: 206

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.

Upvotes: 1

Cristian Deluxe
Cristian Deluxe

Reputation: 130

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

Upvotes: 1

deceze
deceze

Reputation: 522626

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.

Upvotes: 0

Related Questions