Here's a very simple example to get you started
Construct 
$joins as array:$joins = array(
    array(
        'table' => 'table2',
        'condition' => 'table2.id = table1.id',
        'jointype' => 'LEFT'
    ),
);Example function handling joins as an array: public function get_joins($table, $columns, $joins){
    $this->db->select($columns)->from($table);
    if (is_array($joins) && count($joins) > 0)
    {
        foreach($joins as $k => $v)
        {
            $this->db->join($v['table'], $v['condition'], $v['jointype']);
        }
    }
    return $this->db->get()->result_array();
} 
 
 
 
No comments:
Post a Comment