Answers for "optimized sql in codeigniter"

SQL
0

optimized sql in codeigniter

// getData Optimized
    public function getData($table, $cond = '', $field = '', $orderby = '', $limit = '', $join = '')
    { 
        if ($field == '') {
            $field = '*';
        }

        $this->db->select($field);
        $this->db->from($table); 

        if (is_array($join) && count($join) > 0) {
             foreach ($join as $k => $v) {
                $this->db->join($v['table'], $v['condition'], $v['type']);
             }
        }

        if ($cond != '') {
            $this->db->where($cond);
        }

        if ($orderby != '') {  
            $this->db->order_by($orderby['0'], $orderby['1']);
        }  

        if ($limit != '') {  
            $this->db->limit($limit);
        }  

        $result = $this->db->get()->result();
        return $result;
    }
Posted by: Guest on December-09-2020

Code answers related to "optimized sql in codeigniter"

Code answers related to "SQL"

Browse Popular Code Answers by Language