[eluser]Sunjith[/eluser]
Thanks Champs.
That would work if no further aliasing is done. Like:
Code:
/**
* get_property_list
*
* Get Property List
* @author Hermawan Haryanto
* @access public
* @param array
* @return object/false
*/
function get_property_list ($attributes = array())
{
$this->db->select ('suburb.id, suburb.name, COUNT(property.id) total');
if (count ($attributes) >= 1)
{
if (isset ($attributes['type']) AND $attributes['type'] != '')
$this->db->where ('property.type_code_fk', $attributes['type']);
}
$this->db->groupby ('suburb.id');
$this->db->join ('property', 'suburb.id = property.suburb_id_fk', 'left');
$query = $this->db->get ('suburb');
print $this->db->last_query();
return ($query->num_rows() >= 1) ? $query->result() : false;
}
It will return:
Code:
SELECT suburb.id, suburb.name, COUNT(property.id) total FROM mb_suburb AS suburb LEFT JOIN mb_property AS property ON suburb.id = property.suburb_id_fk GROUP BY suburb.id
Wouldn't it?