Re: Model Association Query....stumped

2008-02-08 Thread EchoChargen

I've done the following:
Clipranking Model:
function findClipByRank($site_id){
return $this-query(SELECT Clipranking.rank, 
Clipranking.site_id,
Clipranking.required, Clip.id, Clip.name, Clip.length FROM
cliprankings AS Clipranking, clips AS Clip WHERE Clipranking.site_id =
$site_id AND Clipranking.clip_id = Clip.id);
}

And calling in my controller works fine: $clip = $this-Site-
Clipranking-findClipByRank($id);

In my short experience with Cake, it seems that there would be a more
Cake-ish way to accomplish this.   I'm a noob here so, it's probably
obvious.

Thanks,
Jeremy
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Model Association Query....stumped

2008-02-07 Thread EchoChargen

All -
I've been using Mariano Iglesias Bindable behavior with 1.2 beta to
nice effect, but I've run into a query I can't figure out.  Here's
what I have:
Team hasMany Clip
Team hasMany Site
Site hasMany Clipranking

A Site can play any of the Clips available in their Team in whatever
ranked order they wish.  The Clipranking table contains a field 'rank'
and 'clip_id'.  Clipranking and Clip are not related (at least not
now...).  In my Sites controller I want to retrieve all the
Cliprankings and get the Clip data that corresponds to the 'clip_id'.
I can't seem to get a query or on the fly BindModel() that will get me
what I want.
I guess I'm obtuse.   I've never done a HBTM relationship before, and
maybe that's what I need?  I'm open to any suggestions or noob
sledgehammering for not seeing it.

Much obliged,
Jeremy
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---