I guess the hasOne relation does not work because you do not have a
tag_id in your story table. The "link" can't be done at this level.
You could use the finderQuery parameter, maybe into the HABTM
association.
This thread is very helpfull for the syntax of the finderQuery :

http://groups.google.com/group/cake-php/browse_thread/thread/5ac2bdec0cc6115b


On Jul 7, 7:37 pm, inVINCable <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> Alright, this problem has troubled me for the past four hours so I
> have to resort to the group : \
>
> Ok, I have a HABTM between stories, tags, and my join table is
> stories_tags. I have my search function set up very simply like this
> in my tag controller
>
> function search($tag) {
>  $this->Story->Tag->findAllByTag($tag));
>
> }
>
> The search works perfect fine, the only problem is it returns the
> results from ALL the schools. An example of a return array of the tag
> "computer"
>
>   Array
> (
>     [0] => Array
>         (
>             [Tag] => Array
>                 (
>                     [id] => 30
>                     [tag] => Computer
>                 )
>
>             [Story] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 117
>                             [title] => I went
>                             [body] => to the store
>                             [school_id] => 1
>                             [user_id] => 72
>                             [category_id] =>
>                             [agree] =>
>                             [disagree] =>
>                             [tags] => Computer
>                         )
>
>                     [1] => Array
>                         (
>                             [id] => 118
>                             [title] => new
>                             [body] => story
>                             [school_id] => 3
>                             [user_id] => 72
>                             [category_id] =>
>                             [agree] =>
>                             [disagree] =>
>                             [tags] => Computer
>                         )
>
>                 )
>
> Notice in the returned array in the stories there is a value
> "school_id" My goal is when a user searches for the tag computer, only
> the tags will show up relevant to their school. So this is what I have
> been doing, but to no avail. I have been create a model on the fly, in
> my tags controller, like so:
>
> this->Tag->bindModel(
>                 array('hasOne' => array('Story'=>
>                 array('className' => 'Story',
>                 'cinditions' => 'Story.school_id = 3')
>
> I must be doing something wrong though, so if anyone could offer any
> tips as to what my bindModel should look like that would be great.
> Thanks.


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

Reply via email to