Does anyone know if you can use table aliases in ActiveRecord joins?
Doing the below query just gives me a fatal error saying I’ve run out of memory (with the memory limit set to 250M), but if I remove the table aliases it works.
<?php
$cats = array(1,28);
$this->EE->db->select('*');
$this->EE->db->join('exp_category_posts as cp', 'cp.entry_id = t.entry_id');
$this->EE->db->join('exp_channel_data as d', 'd.entry_id = t.entry_id');
$this->EE->db->join('exp_categories as c', 'c.cat_id = cp.cat_id');
$this->EE->db->where('t.channel_id', 3);
$this->EE->db->where_in('cp.cat_id', $cats);
$query = $this->EE->db->get('exp_channel_titles as t');
var_dump($query);
?>Is there something special I have to do to get an alias to work or will they just not work in this situation?
You mean like?
EXPLAIN SELECT * FROM exp_channel_titles as t
JOIN exp_category_posts as cp ON cp.entry_id = t.entry_id
JOIN exp_channel_data as d ON d.entry_id = t.entry_id
JOIN exp_categories as c ON c.cat_id = cp.cat_id
WHERE t.channel_id = 3 AND cp.cat_id IN (1,28)I get this
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.