hasAndBelongsToMany relation issue

2008-04-09 Thread inma
Hi, I have an User class and a PermissionGroup class. User has defined a hasAndBelongsToMany relation with PermissionGroup. If into database exists one user with two permission grups assigned, when I run this code: $userA = $this-User-findAll($sort, $limit, $page); //gets all the User records

Re: hasAndBelongsToMany relation issue

2008-04-09 Thread Joel
Take a look at the Set class in the cake core. More specifically, the Set::extract() method. Read http://www.thinkingphp.org/2007/02/24/cake-12s-set-class-eats-arrays-for-breakfast/ for a few pertinent examples. -Joel. On Apr 9, 10:28 am, inma [EMAIL PROTECTED] wrote: Hi, I have an User

Re: hasAndBelongsToMany relation issue

2008-04-09 Thread [EMAIL PROTECTED]
The usual and unhelpful answer applies: You will have to rearrange your array-data yourself if you need it in that format. I would take another look at the javascript-component you are using... because I can't really figure out why it would require the data in that format. Repeating the

Re: hasAndBelongsToMany relation issue

2008-04-09 Thread Joel
The query: $records = $this-Author-findAll(); will return nested associative arrays in the form: Array ( [0] = Array ( [Author] = Array ( ...// Fields from the Author model ) [Book] = Array