开发者

dayname(curdate()) NOT working in codeigniter php

开发者 https://www.devze.com 2023-03-07 03:07 出处:网络
This sql works in phpmyadmin but not working in codeigniter php function getProgramsHomepage(){ $data = array();

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号