![]() |
I have a json encoded some value in my table and in that value i have **deadline ** as a string which i want to compare with current date. i have tested the verbal code in sql
SELECT * FROM `posts` where REPLACE(JSON_EXTRACT(extra_info,'$.deadline'),'\"', '') > CURRENT_DATE; its working fine but when i use the codeigniter RawSql() method in where clause in model its not working, i dont understand whats the problem? can any expert check and suggest whats the problem in my code and how to solve this using this rawsql() method? $this->builder = $this->db->table('posts'); $this->builder->where(new RawSql("REPLACE(JSON_EXTRACT('posts.extra_info', '$.deadline'),'\"', '') > CURRENT_DATE")); $this->builder->limit($perPage,$offset)->get()->getResult(); Codeigniter version is 4.3.3
Check the SQL generated by the Model.
See https://www.codeigniter.com/user_guide/d...ml#dbquery
Solved it. 'posts.extra_info' should be posts.extra_info without apostrophe. Thanks to all apostrophe
|
Welcome Guest, Not a member yet? Register Sign In |