>
> How do I limit the columns from the second quarry?

You set limit propertie in your hasMany relationship, like:

$this->Category->hasMany['Script']['limit'] = 10;
$this->Category->find...

Also, why is cake not doing a join, but instead two separate quarries?
> wouldn't that be faster?

Joins are used in belongsTo and hasOne relationship.


[]'s

On Mon, Jun 23, 2008 at 7:14 PM, Turnquist, Jonah <[EMAIL PROTECTED]>
wrote:

>
> Ok, now I have another question.  I understand that I can set 'fields'
> to return only some of the table columns of the categories table.  But
> how do I limit the columns returned from the Scripts/Entries table
> which also gets pulled because of my hasMany definition?
>
> 1       SELECT `Category`.`name`, `Category`.`id` FROM `categories` AS
> `Category` WHERE `Category`.`id` = 2 LIMIT 1
>
> 2       SELECT `Script`.`id`, `Script`.`title`, `Script`.`description`,
> `Script`.`content`, `Script`.`category_id`, `Script`.`user_id`,
> `Script`.`created`, `Script`.`modified` FROM `scripts` AS `Script`
> WHERE `Script`.`category_id` IN (2)
>
> How do I limit the columns from the second quarry?  Doing this
> prevented it from pulling `created` from Categories:
> $this->set('category', $this->Category->read('name')); //(it still
> pulls the id though, so I am assuming you can not prevent that)
> //or (seems to do the same thing)
> $this->set('category', $this->Category->find(array('id' => $id),
> 'name'));
>
> Also, why is cake not doing a join, but instead two separate quarries?
> wouldn't that be faster?
>
> I would think this would work:
> $this->set('category', $this->Category->find( array('id' => $id),
> array('Category.name', 'Script.title', 'Script.description') ));
> But it doesn't! grr
>
> Thanks,
> Jonah
>
> >
>


-- 
Renan Gonçalves - Software Engineer
Cell Phone: +55 11 8633 6018
MSN: [EMAIL PROTECTED]
São Paulo - SP/Brazil

--~--~---------~--~----~------------~-------~--~----~
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