Hello again :-)

Ok, I think I understand, misinterpreted your question.

I am not sure, if this is the best solutioin (honestly I don't think
so), but you could do a custom query


... in the UsersController:
_________________________________________
     $query = <<< SQL
select
  Users.id as user_id,
  Users.name as user_name,
  Singers.id as singer_id,
  Singers.name as singer_name,
  count(Songs.id) as songs_in_lib
from
  Users left join Songs_users on Users.id = Songs_users.user_id,
  Singers left join Singers_songs on Singers.id =
Singers_songs.singer_id,
  Songs
where
  Songs.id = Singers_songs.song_id and
  Songs_users.song_id = Songs.id and
  Users.id = 1
group by
  Users.id,
  Users.name,
  Singers.id,
  Singers.name
order by
  Users.name,
  Singers.name
SQL;

     $data = $this->User->query($query);
     $this->set('data',$data);
_________________________________________

In this case, we know the user ("User.id = 1"). "count(Songs.id) as
songs_in_lib" gives you the number of songs by an singer in this users
library.

I hope that helps you a little. It would be nice to know, if it is
nescessary to fetch all data at once ... you could do it in more than
one step. This depends on how die GUI works, for example: list users ->
klick on user -> show all singers in his library ...??

Regards, Christoph :-)


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to