get result from database equal today - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: get result from database equal today (/showthread.php?tid=79163) |
get result from database equal today - viracoders - 05-02-2021 I need to get posts of today from database using where. PHP Code: // Get Today Time in Model (getLatest): PHP Code: $builder = $this->db->table('posts p'); How do can I generate this query using where OR another method? RE: get result from database equal today - includebeer - 05-02-2021 You can write custom where clause, see number 4 Custom string on this page: http://codeigniter.com/user_guide/database/query_builder.html#looking-for-specific-data Try this: PHP Code: $builder->where('created_at >= CURRENT_DATE'); If CI try to protect the field name and mess the query, try this: PHP Code: $builder->where('created_at >= CURRENT_DATE', null, false); |