本文介绍了带有codeigniter的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何想法,为什么我得到一个语法错误与此?
$ this-> db-> select(DATE_FORMAT(。$ this-> news_articles_table。'date_posted','%M%D,%Y');
UPDATE:
$ this-> db-> select(DATE_FORMAT (。$ this-> news_articles_table。'date_posted','%M%D,%Y');
解决方案问题隐藏在错误消息。请查看您的SQL查询语法:
DATE_FORMAT(news_articles'.date_posted',`'%M`%D, %Y')`
看起来不对,是吗?
因为。因此,要解决这个问题,您需要将 FALSE 传递给 $ this-> db-> select()$
这应该可以工作:
$ this-> db-> select(DATE_FORMAT(。$ this-> news_articles_table。。date_posted,'%M%D,%Y'假);
Any ideas onto why I'm getting a syntax error with this?
$this->db->select("DATE_FORMAT(".$this->news_articles_table."'.date_posted', '%M %D, %Y'");UPDATE:
$this->db->select("DATE_FORMAT(".$this->news_articles_table."'.date_posted', '%M %D, %Y')");解决方案The problem is hidden in the error message. Take a look at your SQL query syntax:
DATE_FORMAT(news_articles'.date_posted', `'%M` %D, `%Y')`That doesn't look right, does it?
Because CI is trying to auto-protect your column names. So, to fix this, you need to pass FALSE to the second parameter of $this->db->select(), which will stop CI from trying to auto-protect these names.
This should work:
$this->db->select("DATE_FORMAT(".$this->news_articles_table.".date_posted, '%M %D, %Y')", FALSE);
这篇关于带有codeigniter的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!