Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter模型在我的查询中插入额外字符_Php_Codeigniter - Fatal编程技术网

Php CodeIgniter模型在我的查询中插入额外字符

Php CodeIgniter模型在我的查询中插入额外字符,php,codeigniter,Php,Codeigniter,我正在CodeIgniter模型中执行一个查询以下是我的代码: if($query = $this->db->select('postID, users.userID, users.userFirstName, users.userLastName, postTitle, postDescription, postHtmlContent, date_format(creationDate, "%d %b, %Y") as creationDate, date_format(updat

我正在CodeIgniter模型中执行一个查询以下是我的代码:

if($query = $this->db->select('postID, users.userID, users.userFirstName, users.userLastName, postTitle, postDescription, postHtmlContent, date_format(creationDate, "%d %b, %Y") as creationDate, date_format(updationDate, "%d %b, %Y") as updationDate, cover, postType')->from('posts, users')->where('users.userID = posts.userID and postID = 1 and postStatus = "APPROVED"')->get()){
            return $query->result()[0];
        }else{
            return NULL;
        }
虽然在mysql控制台上执行此查询工作正常,但在CodeIgniter的活动记录模式下,
date\u格式
部分引入了一些额外字符。这是CodeIgniter显示的错误,所有额外字符都以
date\u格式清晰可见(creationDate,
%d
%b,
%Y”)
部分

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM (`posts`, `users`) WHERE `users`.`userID` = posts.userID and postID = 1 and' at line 2

SELECT `postID`, `users`.`userID`, `users`.`userFirstName`, `users`.`userLastName`, `postTitle`, `postDescription`, `postHtmlContent`, date_format(creationDate, `"%d` %b, `%Y")` as creationDate, date_format(updationDate, `"%d` %b, `%Y")` as updationDate, `cover`, `postType` FROM (`posts`, `users`) WHERE `users`.`userID` = posts.userID and postID = 1 and postStatus = "APPROVED"

我该如何处理这个问题?如有任何帮助,将不胜感激。感谢您删除反勾号,您必须向所选零件添加第二个可选参数(FALSE):

$this->db->select("postID, userID, . . .", FALSE);

只需添加
false
作为select的第二个参数,这样codeigniter就不会转换格式

if($query = $this->db->select('postID, users.userID, users.userFirstName, users.userLastName, postTitle, postDescription, postHtmlContent, date_format(creationDate, "%d %b, %Y") as creationDate, date_format(updationDate, "%d %b, %Y") as updationDate, cover, postType',false)->from('posts, users')->where('users.userID = posts.userID and postID = 1 and postStatus = "APPROVED"')->get()){
        return $query->result()[0];
    }else{
        return NULL;
    }

谢谢,我在某处看到过,但没有找到任何关于为什么要添加此项的参考。