DATE_FORMAT in CodeIgniter

The date_format() function returns a date formatted according to the specified format. Let’s create a date_format() in where condition using codeigniter. if(!empty($this->input->get(‘start_date’))) { $this->db->where(‘DATE_FORMAT(products.created_datetime,”%Y-%m-%d”) >=’, date(‘Y-m-d’,strtotime($this->input->get(‘start_date’)))); }

Read MoreDATE_FORMAT in CodeIgniter

Grouping Query in Codeigniter

Query grouping allows you to create groups of WHERE clauses by enclosing them in parentheses. This will allow you to create queries with complex WHERE clauses. Nested groups are supported. $this->db->select(‘*’)->from(‘tbl_user’) ->group_start() ->where(‘a’, ‘a’) ->or_group_start() ->where(‘b’, ‘b’) ->where(‘c’, ‘c’) ->group_end()…

Read MoreGrouping Query in Codeigniter