Hi AD,

>> I think what I want is a habtm that can connect to multiple models
>> with some additional fields in the join table, but I'm not sure that's
>> feasible, but hope it is.
>
> a join table with more than 2 fields is a model, and a model that can
> link to anything is (as you know) polymorphic.
>
> Therefore you want a join table something like this:
>
> relations
>  id
>  model
>  foreign_id
>  url
>  title
>  related_model
>  related_foreign_id
>  related_url
>  related_title
>
> which would allow you to relate anything to anything. I wouldn't use
> the polymorphic behavior though. just create a method for returning
> you related stuff - unless you denormalize as hinted above so you
> don't even need to.
>
> class Relation extends AppModel {
>  function related($model, $id) {
>  $return = array();
>  $data = $this->find('all', array('conditions' => array(
>   'OR' => array(
>     array('model' => $model, 'foreign_id' => $id),
>     array('related_model' => $model, 'related_foreign_id' => $id),
>   )
>  );
>  }
>  .. efficiently loop and get data if at all necessary
>  return $return;
> }

Ahh, ok - thanks. Will have a play then hit you back if I come unstuck.

Cheers,

jb


-- 
jon bennett - www.jben.net - blog.jben.net

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to