Wednesday, April 1, 2009

Re: Does anybody know how can I limit the join table fields when I user joins condition?

Yes, we can use containable to get the task's users. But if there is a user , I want to find all the tasks he owns. How can I do?

User table:
id | name

Task table:
id | user_id | name

We can't count on containable to help us to find the relate tasks. And I count on 'join' to  help me to do this. Any suggestions?

On Wed, Apr 1, 2009 at 2:09 AM, Amit <amit@amitvaria.com> wrote:

I highly recommend checking out the Containable behavior:

http://book.cakephp.org/view/474/Containable

It will simplify this code and let you easily add fields.

On Mar 31, 8:28 am, joshua <josh...@gmail.com> wrote:
> For example:
> One task has many users.
> ########################
>         $condition = array();
>         $condition['joins'] = array(
>             array(
>                 'table' => 'users',
>                 'alias' => 'User',
>                 'type' => 'inner',
>                 'foreignKey' => 'user_id',
>                 'conditions'=> array('User.id =
> Task.user_id','User.deleted=0')
>         ));
> ########################
> I just want to find the user name , not all the fields in User table. I try
> to add the 'fields' property in this array, but it seems not.
> --
> Thanks
> Joshua




--
Thanks
Joshua

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: