BTW i am using CakePHP 1.2
On Jun 20, 9:33 pm, "Turnquist, Jonah" <[EMAIL PROTECTED]> wrote:
> Ok, so I have a Scripts table, holding php script entries (tutorials),
> a Categories table, and a Users table. Each script has a category and
> a user. I have all the hasMany belongsTo etc set up properly.
>
> On my /scripts page, under the index action it lists all of the
> scripts, displaying the script title, and it's user that created it,
> but not it's category. So it should not even fetch category data. So
> this is what it needs to fetch:
>
> [0] => Array
> (
> [Script] => Array
> (
> [id] => 1
> [title] => DB connect
> [created] => 2001-06-18 16:05:40
> [description] => This class that will connect to the
> database test
> )
>
> [User] => Array
> (
> [name] => man
> [id] => 1
> )
>
> )
>
> The find() code that is working and doing the above:
>
> $this->set('scripts', $this->Script->find('all', array(
> //'recursive' => -1, //this is commented out
> 'fields' => array('Script.id', 'Script.title', 'Script.created',
> 'Script.description', 'User.name', 'User.id'),
> )
> ));
>
> Setting the 'fields' option kept it from returning any categories
> data.
>
> This successfully returns the correct data. BUT, when I looked at the
> quarries, I saw a problem:
> 1) DESCRIBE `scripts`
> 2) DESCRIBE `categories` //not needed!
> 3) DESCRIBE `users`
> 4) SELECT `Script`.`id`, `Script`.`title`, `Script`.`created`,
> `Script`.`description`, `User`.`name`, `User`.`id` FROM `scripts` AS
> `Script` LEFT JOIN `categories` AS `Category` ON
> (`Script`.`category_id` = `Category`.`id`) LEFT JOIN `users` AS `User`
> ON (`Script`.`user_id` = `User`.`id`) WHERE 1 = 1 //excessive!
>
> You see, it is doing a left join on categories in quarry #4, and
> quarry #2 is not even needed. I understand joins can be slow. Thus I
> am asking how can I get rid of it
>
> I tried setting the option 'recursive' => -1 (you can see it commented
> out), but that obviously stops it from collecting the user data too.
> So I guess what I need is a partial recursion? So it performs
> recursion to the Users table but not the Categories table? How can
> this be done? any ideas?
>
> Thanks,
> Jonah (is very new to cake BTW, try not to use big words lol
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---