Welcome Guest, Not a member yet? Register   Sign In
Get today's posts
#9

(This post was last modified: 09-18-2019, 10:47 AM by tp45.)

(09-18-2019, 10:19 AM)jreklund Wrote: Here are a couple of ways you can write that SQL. If you can, you should write them as plain SQL, it's faster.

PHP Code:
ok thanks @jreklund let me try 

(09-18-2019, 10:40 AM)tp45 Wrote:
(09-18-2019, 10:19 AM)jreklund Wrote: Here are a couple of ways you can write that SQL. If you can, you should write them as plain SQL, it's faster.

public function today_post(){
    
$datebytimezone = new DateTime("now", new DateTimeZone('UTC'));
    
$date $datebytimezone->format('Y-m-d');
    
$query $this->db->get_where('post',
        array(
            
'posted_at >=' => "{$date} 00:00:00",
            
'post_closed' => 0
        
)
    );
    return 
$query->num_rows();
}
This one works the others are have CURDATE() in which i get an error like curdate() not recofnized as an intenally or inbuld function.
Thank you so much @jreklund as always, you a legend.
Reply


Messages In This Thread
Get today's posts - by tp45 - 09-17-2019, 08:35 AM
RE: Get today's posts - by jreklund - 09-17-2019, 11:53 AM
RE: Get today's posts - by tp45 - 09-17-2019, 01:05 PM
RE: Get today's posts - by demyr - 09-17-2019, 01:25 PM
RE: Get today's posts - by tp45 - 09-17-2019, 02:12 PM
RE: Get today's posts - by demyr - 09-17-2019, 02:16 PM
RE: Get today's posts - by tp45 - 09-17-2019, 04:33 PM
RE: Get today's posts - by jreklund - 09-18-2019, 10:19 AM
RE: Get today's posts - by tp45 - 09-18-2019, 10:40 AM
RE: Get today's posts - by jreklund - 09-18-2019, 11:34 AM
RE: Get today's posts - by tp45 - 09-18-2019, 02:58 PM
RE: Get today's posts - by jreklund - 09-19-2019, 10:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB