Codeigniter and MYSQL DateTime

I have a request:

$query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null, 'Date'=> 'NOW()'));

The Date field is a type of date and time, and I want them to write records where their date is the same as today, however above, and everything else that I'm tired does not work.

Can someone show me how to pull the records that date it today correctly, ignoring the time part of the datetime.

Thanks for any help

UPDATE

Now I converted the request to the following

$start = date('Y-m-d 00:00:00');
    $end = date('Y-m-d 23:59:59');
    $query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null, 'Date' => 'BETWEEN '.$start.' AND '.$end));

However, still no luck, simply without reconfiguring any results!

+3
source share
4 answers
$params = array('Status' => 0, 'Booking_Date'=> date('Y-m-d'));
$this->db->query('SELECT * FROM Bookings WHERE Status=? AND Driver_ID Is Null AND    Date(Booking_Date) = ?',$params);

Think what will work

+2
source

I would try

$this->db->where('Status', 0);
$this->db->where('Driver_ID', null);
$this->db->where('DATE(Date)', date('Y-m-d'), FALSE);
$query = $this->db->get('Bookings');
+4
source

, DateTime NOW(). , NOW() DateTime, "YYYY-MM-DD", "HH: MM: SS".

, , " , Date , ". , , - " , Date ".

DateTime . "" , , MySQL DATE(), NOW(), DateTime, CURDATE(), . CodeIgniter, :

$query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null, 'DATE(Date)'=> 'CURDATE()'));

( , MySQL $this->db->get_where).

+1

MySql date("Y-m-d H:i:s").

Thus, you will need to get everything for the current day, so where someything like;

SELECT * FROM `Bookings` WHERE `Date` BETWEEN date("Y-m-d 00:00:00") AND date("Y-m-d 23:59:59")
0
source

All Articles