dayname(curdate()) 不适用于 codeigniter php
此 sql 在 phpmyadmin 中有效,但在 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){
foreach($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
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){
foreach($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DAYNAME(CURDATE())
将尝试执行 PHP 函数CURDATE
和DAYNAME
,您需要以 CI 所支持的方式将它们作为字符串传递不会逃脱。这应该可以做到:DAYNAME(CURDATE())
will try to execute the PHP functionsCURDATE
andDAYNAME
, you need to pass them as strings in a way that CI will not escape. This should do it:您必须将 'DAYNAME(CURDATE())' 写为字符串
You must write 'DAYNAME(CURDATE())' , as a string