EDIT :
I just added my code above
1) you could use find_by_sql ... and build your query as you had it before
2) obvious error
in the table you call it the column `ref`
in your conditions statement you name it `type` ... if it's not a failure by copy (anonymizing for this forum) try calling the columns in your query like you have them in the actual tables (referring to the conditions - lines in both queries)
And I wouldnt use LIKE for this conditions , use = (and put a proper index on the ref-column)
public static $has_many = array(
array(
'terms',
'through' => 'relationships',
'conditions' => array('ref = ?', 'Event')
'foreign_key' => 'ref_id'
)
);
public static $has_many = array(
array(
'terms',
'through' => 'relationships',
'conditions' => array('ref = ?', 'Venue'),
'foreign_key' => 'ref_id'
)
);
Sven Leuschner wrote:
And I wouldnt use LIKE for this conditions , use = (and put a proper index on the ref-column)
Thanks mate, it was exaclty why it didn't worked. Thanks again for your help
:)
(1-3/3)
Subject: has_many through does not retreive the data
Hi everyone,
I'm totally new on that forum. I recently start using this wonderfull library. Everything works fine.
However, I have a small issue using the relation has_many through.
Let me explain. I'm working on a "Taxonomy" system. Here my tables used for the taxonomy system :
http://pastie.org/7444899
So far, here is what I did :
http://pastie.org/7444918
It works fine but how can I filter my date. Let's say for example, from the Event, I want only the term_relationship with ref == Event ?
Thanks in advance for you precious help.