Re: Binding my assocation on the fly to sort through a HABTM relationship...
Well I did not have time to think much about the query, but maybe the bindModel could look like this : $this-Story-bindModel( array( 'hasAndBelongsToMany' = array( 'className'='Tag', 'finderQuery' = SELECT . Tag.id, . Tag.name, . FROM . tags AS Tag . JOIN stories_tags ON (Story.id = stories_tags.story_id) . WHERE . Tag.name = $name AND . Story.school_id = $_SESSION['school_id'] ) ) Again, I might be completely wrong and really did not test anything.. This was just to give you some hints Hope this helps On Jul 7, 8:18 pm, inVINCable [EMAIL PROTECTED] wrote: Heh, yeah I fixed it, still no dice :( No Story.tag_id field On Jul 7, 11:12 am, Tim Koschuetzki [EMAIL PROTECTED] wrote: Typo in the last line of the binding operation: 'cinditions' ; ] On 7 Jul., 19:58, inVINCable [EMAIL PROTECTED] wrote: francky06I, I think a problem would occur because the variable depending on what school_id is in their session, so if I put that in the finderQuery, would that work? It return results based upon their school only ? I was thinking about 'finderQuery' = 'where school_id = $session-read(User.school_id)' Although I guess this will not work because the model cannot be changed for every user that calls upon it? Thanks. On Jul 7, 10:49 am, francky06l [EMAIL PROTECTED] wrote: 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/5ac2bdec... 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
Binding my assocation on the fly to sort through a HABTM relationship...
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 -~--~~~~--~~--~--~---
Re: Binding my assocation on the fly to sort through a HABTM relationship...
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 -~--~~~~--~~--~--~---
Re: Binding my assocation on the fly to sort through a HABTM relationship...
francky06I, I think a problem would occur because the variable depending on what school_id is in their session, so if I put that in the finderQuery, would that work? It return results based upon their school only ? I was thinking about 'finderQuery' = 'where school_id = $session- read(User.school_id)' Although I guess this will not work because the model cannot be changed for every user that calls upon it? Thanks. On Jul 7, 10:49 am, francky06l [EMAIL PROTECTED] wrote: 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/5ac2bdec... 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 -~--~~~~--~~--~--~---
Re: Binding my assocation on the fly to sort through a HABTM relationship...
Typo in the last line of the binding operation: 'cinditions' ; ] On 7 Jul., 19:58, inVINCable [EMAIL PROTECTED] wrote: francky06I, I think a problem would occur because the variable depending on what school_id is in their session, so if I put that in the finderQuery, would that work? It return results based upon their school only ? I was thinking about 'finderQuery' = 'where school_id = $session-read(User.school_id)' Although I guess this will not work because the model cannot be changed for every user that calls upon it? Thanks. On Jul 7, 10:49 am, francky06l [EMAIL PROTECTED] wrote: 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/5ac2bdec... 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 -~--~~~~--~~--~--~---
Re: Binding my assocation on the fly to sort through a HABTM relationship...
P.S. franckyl, You were right, it does not work because there is no tag_id field in my story table. On Jul 7, 10:58 am, inVINCable [EMAIL PROTECTED] wrote: francky06I, I think a problem would occur because the variable depending on what school_id is in their session, so if I put that in the finderQuery, would that work? It return results based upon their school only ? I was thinking about 'finderQuery' = 'where school_id = $session-read(User.school_id)' Although I guess this will not work because the model cannot be changed for every user that calls upon it? Thanks. On Jul 7, 10:49 am, francky06l [EMAIL PROTECTED] wrote: 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/5ac2bdec... 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 -~--~~~~--~~--~--~---
Re: Binding my assocation on the fly to sort through a HABTM relationship...
Heh, yeah I fixed it, still no dice :( No Story.tag_id field On Jul 7, 11:12 am, Tim Koschuetzki [EMAIL PROTECTED] wrote: Typo in the last line of the binding operation: 'cinditions' ; ] On 7 Jul., 19:58, inVINCable [EMAIL PROTECTED] wrote: francky06I, I think a problem would occur because the variable depending on what school_id is in their session, so if I put that in the finderQuery, would that work? It return results based upon their school only ? I was thinking about 'finderQuery' = 'where school_id = $session-read(User.school_id)' Although I guess this will not work because the model cannot be changed for every user that calls upon it? Thanks. On Jul 7, 10:49 am, francky06l [EMAIL PROTECTED] wrote: 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/5ac2bdec... 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 -~--~~~~--~~--~--~---