![](/img/trans.png)
[英]Using slashes in the where clause while comparing values in active record codeigniter
[英]how to fetch record in codeigniter where clause using json values
我的問題是在我的表中存儲了json編碼的值,如field Name : offer_promotion
[{"name":"sample promotion","price":"1555","expdate":"2017-05-15","shortdesc":"test","longdesc":"test"}]
現在我想為選擇記錄編寫查詢,例如,對於eaxmple:
$this->db->where('offer_promotion', "name":"sample promotion");
怎么寫這個查詢?
數據庫中的json作為一個簡單的字符串。 所以你必須應用類似於字符串的邏輯。 你可以使用Like
$this->db->like('offer_promotion', '%"name":"sample promotion"%');
$some = json_decode($json);
$this->db->where('offer_promotion',$some['name']);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.