Re: Limiting Results with HABTM FindAll

2007-04-30 Thread Headzoo

Scratch that question. I found *an* answer, which is to change the
$hasAndBelongsToMany variable prior to the findAll() call, and adding
a limit clause to it.  That seems a little sloppy though, and I'm
wondering if there is a better way.

- Sean


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Limiting Results with HABTM FindAll

2007-04-30 Thread Headzoo

Hi all,
I have a db setup that's nearly identical to the hasAndBelongsToMany
example in the CakePHP manual. There is a posts table, tags table, and
post_tags table.

If I want to find all posts with a particular tag, I use this code:

$tag_name = 'something';
$data = $this->Tag->findAll("Tag.tag = '$tag_name'");

The problem I'm running into, is finding a way to limit the number of
posts that are returned.  The above code will return *all* the posts
with the particular tag, but I only want the last 20 or so.  Adding a
limit to the findAll() method only limits the number of rows returned
from the Tag model, not the Post model.

Can anyone tell me how to put limit clauses on the models related to
the model I'm using findAll() on?

- Sean


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---