How do you do multiple Joins?
I tried to do some thing like this:
{exp:activerecord select="entry_id, title, url_title, comment_total, field_id_17 as article_excerpt, view_count_one, screen_name as author" from="exp_channel_titles" join="exp_members" on="exp_members.member_id = exp_channel_titles.author_id" join_type="inner" join="exp_channel_data" on="exp_channel_data.entry_id = exp_channel_titles.entry_id" join_type="left" join="exp_relationships" on="exp_relationships.rel_id = exp_channel_data.field_id_19" join_type="left" where:rel_child_id="{entry_id}" order_by="entry_date DESC" limit="10" paginate="bottom" }
Only the last join will ever be used.
Generated SQL:
SELECT `entry_id`, `title`, `url_title`, `comment_total`, `exp_channel_data`.`field_id_17` as article_excerpt, `view_count_one`, `screen_name` as author FROM (`exp_channel_titles`) LEFT JOIN `exp_relationships` ON `exp_relationships`.`rel_id` = `exp_channel_data`.`field_id_19` WHERE `rel_child_id` = '593' ORDER BY `entry_date` DESC LIMIT 10
Dumped the $this->EE->TMPL->tagparams and this is the output:
Array ( [select] => entry_id, title, url_title, comment_total, exp_channel_data.field_id_17 as article_excerpt, view_count_one, screen_name as author [from] => exp_channel_titles [join] => exp_relationships [on] => exp_relationships.rel_id = exp_channel_data.field_id_19 [join_type] => left [where:rel_child_id] => 593 [order_by] => entry_date DESC [limit] => 10 [paginate] => bottom )
It’s either I am doing something wrong or this plugin doesn’t support multiple joins like normal Active Record does.
Any ideas?
|