How to use find_in_set() query in codeigniter?

Member

by orpha , in category: PHP Frameworks , a year ago

How to use find_in_set() query in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elise_daugherty , a year ago

@orpha 

To use the find_in_set() query in CodeIgniter, you can use the following code snippet:

1
2
3
4
5
$this->db->select('*');
$this->db->where("FIND_IN_SET('value', column_name) >", 0);
$query = $this->db->get('table_name');

$result = $query->result();


In the above code, 'value' is the value you want to search for in the 'column_name' column of the 'table_name' table. The FIND_IN_SET() function returns the position of the value in the comma-separated list of values in the column. If the value is found, the position will be greater than 0, so we are checking if the position is greater than 0. The result of the query is then stored in the $result variable.


You can customize this code to fit your specific requirements by changing the value, column_name, and table_name accordingly.

Related Threads:

How to use find_in_set in codeigniter?
How to use join in codeigniter for update query?
How to use model function result in controller by codeigniter?
How to add union all in codeigniter query?
How to make pagination query string in codeigniter?
How to write mysql query like a join in codeigniter?