Hello,
In case you wants to paginate the result here is the way:
1. Create a model companies_tag, with the association
$belongsTo("Company","Tag",[...]).
2. In your company controller, use this model ($uses) and redefine the
paginate var by adding something like
$paginate = array(
"CompaniesTag" => array('limit' => 10, 'page' => 1, 'order' =>
array('Company.created'=> 'DESC'),"recursiv"=>2)
);
3. Then in you index function
$cond = array('Tag.id' => $tag_id);
$companies = $this->paginate('CompaniesTag', $cond);
4. In your view give an hand to the paginator helper:
$paginator->options = array('model'=>"CompaniesTag", [...]);
Everything is way better explained by cakebaker here:
http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/
Hope this help!
Rémy
> I have two tables, companies and tags, joined by a companies_tags
> table. If I add/edit a company, Cake populates a tags listbox just
> fine.
>
> How can I get a list of the companies that contain certain tags? If I
> try to set a condition "Tag.tag_id IN (1, 2, 3)", I get an SQL error
> (field tags.tag_id not found)
>
> Is there a decent way to do this within the framework? If I want to
> group these companies by their tags, how do I do that? Do I use the
> model query() function?
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---