ok, sounds good to me! Thanx

Jonah

On Jun 21, 6:40 am, Ian Zepp <[EMAIL PROTECTED]> wrote:
> As a general rule, cake needs to know the DB table layouts in order to
> perform queries. As you've seen, unbinding the model associations
> prevents Cake from joining the tables at query time.
>
> RE the describe, however, I wouldn't worry about it for two reasons:
>
> (a) DESCRIBE is essentially a no-cost operation to the DB server. The
> table schema is already stored in memory, so it is returning results
> instantly with o overhead.
> (b) DESCRIBE is cached in a production environment. Only in a dev
> environment are the results not cached, and hence re-fetched each time,
> so that if you make changes to the table schema they are immediately used.
>
> Turnquist, Jonah wrote:
> > Should not have posted so fast.  I seem to have found a solution:
>
> > $this->Script->unbindModel(
> >    array('belongsTo' => array('Category'))
> > );
>
> > That temporally removes the relationship.  Works perfectally to remove
> > the extra join.  But it still performs quarry #2, "DESCRIBE
> > `categories`".  humph.  Why does it do that?
>
> > Thanks,
> > Jonah
>
> > On Jun 20, 9:54 pm, "Turnquist, Jonah" <[EMAIL PROTECTED]> wrote:
> >> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to