Reading nested data

Hi,

if I'm using a table setup like this:

Persons

  • ID
  • Surname
  • Forename

Groups

  • ID
  • Title
  • Admin_ID (is a Person's ID)

Memberships

  • ID
  • Group_ID
  • Person_ID

How is it possible to load

  • one Person's data,
  • his Groups' titles and,
  • the Admin's data of the groups,
  • but NOT all group members' data

using one find() call?

I'm just getting started with CakePHP. Maybe it's a stupid question.

Cheers,

Manuel

Asked by manuels, on 8/2/10

1 Answer

firstly i would recommend having users rather than persons... its much easier when you need auth and related as cake defaults to a User model and not Person

second i would say you should check out the book tutorial, all you questions are answered there. http://book.cakephp.org/view/219/Blog

next learn about bake console. it will do your crud code for you

some other points you should look in to is your conventions... this is what cake expects http://book.cakephp.org/view/22/CakePHP-Conventions and does not look like you code.. you are only making life difficult.

and finally what you need to do what you asked is containable. http://book.cakephp.org/view/474/Containable

Answered by dogmatic69on 8/2/10

<< previous next >>

Rating

0

Viewed

306 times

Last Activity

on 8/2/10