Answers for "like in codeigniter"

PHP
1

like codeigniter

$this->db->like('title', 'match', 'before'); 
 // Produces: WHERE title LIKE '%match' 

 $this->db->like('title', 'match', 'after'); 
// Produces: WHERE title LIKE 'match%' 

$this->db->like('title', 'match', 'both'); 
// Produces: WHERE title LIKE '%match%'
Posted by: Guest on July-01-2021
0

codeigniter where_not_in

$names = array('Frank', 'Todd', 'James');
$this->db->where_not_in('username', $names);
// Produces: WHERE username NOT IN ('Frank', 'Todd', 'James')
Posted by: Guest on October-28-2020
2

codeigniter where order by

$this->db->select('ae_users.employee_id, ae_users.emp_name, ae_users.emp_name2, ae_users.emp_name3');
		$this->db->from('ae_users');                
		$this->db->where_in('ae_users.employee_id',$employee_ids);
                $this->db->_protect_identifiers = FALSE; // stop CI adding backticks
                $order = sprintf('FIELD(ae_users.employee_id, %s)', implode(', ', $employee_ids));
                $this->db->order_by($order);
                $this->db->_protect_identifiers = TRUE; 
		$query =$this->db->get();
               // echo '<pre>'; print_r($this->db->last_query());exit;
		if ($query->num_rows()) {
			return $query->result_array();
		} else {
			return 0;
		}
Posted by: Guest on September-16-2020
0

cideigniter orLike()

$this->db->like('title', 'match'); $this->db->or_like('body', $match);
// WHERE `title` LIKE '%match%' ESCAPE '!' OR  `body` LIKE '%match%' ESCAPE '!'
Posted by: Guest on October-20-2020
1

where group codeigniter

$this->db->select('*')->from('my_table')
        ->group_start()
                ->where('a', 'a')
                ->or_group_start()
                        ->where('b', 'b')
                        ->where('c', 'c')
                ->group_end()
        ->group_end()
        ->where('d', 'd')
->get();

// Generates:
// SELECT * FROM (`my_table`) WHERE ( `a` = 'a' OR ( `b` = 'b' AND `c` = 'c' ) ) AND `d` = 'd'
Posted by: Guest on October-05-2020

Browse Popular Code Answers by Language