Renjitha22
Renjitha22

Reputation: 213

CodeIgniter Active Record equal to for date

In CodeIgniter using active record, how do I perform a date equal to in:

$this->db->where()           

date format: $today_date=date('m/d/Y');

public static function getShop($today_date) {
    $CI = & get_instance();
    $CI->db->select('url');
    $CI->db->where('AddDate', $today_date);
    $CI->db->from('tblShop');
    $query = $CI->db->get();
    return($query->result_array());
}

Maybe someone could help me on this.

Upvotes: 0

Views: 686

Answers (1)

ali shoaib
ali shoaib

Reputation: 11

Please use correct date format to compare to database field, also use MySQL date function to exclude time while comparing.

$today_date=date('Y-m-d');

public static function getShop($today_date) {
    $CI = & get_instance();
    $CI->db->select('url');
    $CI->db->where('DATE(AddDate)', $today_date);
    $CI->db->from('tblShop');
    $query = $CI->db->get();
    return($query->result_array());
}

Upvotes: 1

Related Questions