Skip to content
Advertisement

How to find out if variable value in database json column Codeigniter?

Im using Codeigniter. Im trying to get some value in database like;

$this->db->where('json_value','test1');

the problem is ‘json_value’ column is like = [{"name":"test1","value":"test1"},{"name":"test2","value":"test2"}]

how can I get ‘test1’ if ‘json_value’ has?

Advertisement

Answer

You can use LIKE in your query

$this->db->like('json_value', 'test1', 'both');

For more information read the CI3 documentation.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement