[eluser]alvaroeesti[/eluser]
Hello,
The problem that I am having is in translating the Loop, so that it renders this syntax
Code:
AND (`x`.`id` = '37' OR `x`.`id` = '31' OR `x`.`id` = '36')
being x the city table.
And here is the active record.
Code:
$this->db->select('asset_id, region_name, etc etc);
$this->db->from('asset a');
$this->db->join('region y', 'y.id = a.region_fk');
$this->db->join('city x', 'x.id = a.city_fk');
$this->db->join('seller s', 's.seller_id = a.seller_fk');
$this->db->join('object_type ot', 'ot.type_id = a.object_type_fk');
$this->db->join('duration du', 'du.duration_id = a.duration_fk');
$this->db->join('transaction_type tt', 'tt.transtype_id = a.transaction_type_fk');
$this->db->where('y.id', $regions);
$i = 0;
$nc = sizeof($cities);
if ($nc > 1)
{
$this->db->where('x.id', $cities[$i]);
for($i = 1; $i <sizeof($cities); $i++)
{
$this->db->or_where('x.id', $cities[$i]);
}
}
else {
$this->db->where('x.id', $cities[$i]);
}
...irrelevant code
I need to equal it like I said, to this sql rendering
Code:
AND (`x`.`id` = '37' OR `x`.`id` = '31' OR `x`.`id` = '36')
and what it renders instead is
Code:
AND `x`.`id` = '31'
OR `x`.`id` = '36'
OR `x`.`id` = '37'
which is not quite the same, because of the parentheses etc