Tuesday, February 8, 2022

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

Issue

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?


Solution

You can use LIKE in your query

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

For more information read the CI3 documentation.



Answered By - mail2bapi

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.