php - Select records from date and ignore time portion not working -


i have weird situation. have created calendar codeigniter using built in calendar class. works far grabbing events , putting them on calendar, know selecting dates works... i'm trying select records fall on specific date, such 2014-03-28, no matter query use not pulling records day. have table , start_date date i'm trying pull by, set datetime. ideas i'm doing wrong, here's i've tried (start_date being fed function equal y-m-d. 2014-03-28):

function get_list_events($start_date) {      $start_date_start = date('y-m-d', strtotime($start_date.' 00:00:00'));     $start_date_end = date('y-m-d', strtotime($start_date.' 23:59:59'));      $this->db->where("start_date between '$start_date_start%' , '$start_date_end%'", null, false);     $query = $this->db->get('events');      $data = array();      foreach ($query->result() $row) {     $data[] = array(         'id' => $row->id,         'title' => $row->title,         'description' => $row->description,         'cost' => $row->cost,         'image' => $row->image,         'start_date' => $row->start_date,         'end_date' => $row->end_date,         'venue' => $row->venue,         'venue_address' => $row->venue_address,         'venue_city' => $row->venue_city,         'venue_state' => $row->venue_state,         'venue_zipcode' => $row->venue_zipcode,         'contact_name' => $row->contact_name,         'contact_email' => $row->contact_email,         'contact_phone' => $row->contact_phone,         'contact_website' => $row->contact_website,         'create_date' => $row->create_date,         'active' => $row->active,     );     }     return $data;  } 

also tried obvious way:

function get_list_events($start_date) {      $start_date = date('y-m-d', strtotime($start_date));      $this->db->where('active', 1);     $this->db->where('start_date', $start_date);     $this->db->order_by('start_date', 'desc');     $query = $this->db->get('events');      $data = array();      foreach ($query->result() $row) {     $data[] = array(         'id' => $row->id,         'title' => $row->title,         'description' => $row->description,         'cost' => $row->cost,         'image' => $row->image,         'start_date' => $row->start_date,         'end_date' => $row->end_date,         'venue' => $row->venue,         'venue_address' => $row->venue_address,         'venue_city' => $row->venue_city,         'venue_state' => $row->venue_state,         'venue_zipcode' => $row->venue_zipcode,         'contact_name' => $row->contact_name,         'contact_email' => $row->contact_email,         'contact_phone' => $row->contact_phone,         'contact_website' => $row->contact_website,         'create_date' => $row->create_date,         'active' => $row->active,     );     }     return $data;  } 

and tried this:

function get_list_events($start_date) {      $start_date = date('y-m-d h:i:s', strtotime($start_date.' 00:00:00'));     $start_time = date('y-m-d h:i:s', strtotime($start_date.' 23:59:59'));      $this->db->where('active', 1);     $this->db->where('start_date >=', $start_date);     $this->db->where('start_date <=', $start_time);     $this->db->order_by('start_date', 'desc');     $query = $this->db->get('events');      $data = array();      foreach ($query->result() $row) {     $data[] = array(         'id' => $row->id,         'title' => $row->title,         'description' => $row->description,         'cost' => $row->cost,         'image' => $row->image,         'start_date' => $row->start_date,         'end_date' => $row->end_date,         'venue' => $row->venue,         'venue_address' => $row->venue_address,         'venue_city' => $row->venue_city,         'venue_state' => $row->venue_state,         'venue_zipcode' => $row->venue_zipcode,         'contact_name' => $row->contact_name,         'contact_email' => $row->contact_email,         'contact_phone' => $row->contact_phone,         'contact_website' => $row->contact_website,         'create_date' => $row->create_date,         'active' => $row->active,     );     }     return $data;  } 

any appreciated.

my suggestion use

// ... code above ... $query = $this->db->get('events'); echo $this->db->last_query(); die(); 

and query you're throwing against ddbb. that, you'll able of throw query mysql client , see if rows query ci using.

in fact, first block of code wrote looks well, , others have $this->db->where('active', 1); first 1 haven't, so, again, check queries, xd.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -