Welcome Guest, Not a member yet? Register   Sign In
A patch for JOINs
#3

[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?


Messages In This Thread
A patch for JOINs - by El Forum - 07-01-2007, 04:27 AM
A patch for JOINs - by El Forum - 07-01-2007, 08:52 AM
A patch for JOINs - by El Forum - 07-01-2007, 11:28 PM
A patch for JOINs - by El Forum - 07-02-2007, 12:03 AM
A patch for JOINs - by El Forum - 07-02-2007, 12:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB