dayname(curdate()) NOT working in codeigniter php
This sql works in phpmyadmin but not working in codeigniter php
function getProgramsHomepage(){
$data = array();
$this->db->select("p_name,p_start");
$this->db->where('p_channel', 'tv');
$this->db->where('p_day', DAYNAME(CURDATE()));
$this->db->order_by('id','asc');
//$this->db->limit($limit);
$Q = $this->db->get('programs');
if($Q->num_rows() > 0){
开发者_如何学Go foreach($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
DAYNAME(CURDATE())
will try to execute the PHP functions CURDATE
and DAYNAME
, you need to pass them as strings in a way that CI will not escape. This should do it:
$this->db->where('p_day = DAYNAME(CURDATE())');
You must write 'DAYNAME(CURDATE())' , as a string
精彩评论