codeigniter $ this-> db-> where();自定义字符串问题 [英] codeigniter $this->db->where(); custom string problem
本文介绍了codeigniter $ this-> db-> where();自定义字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用自定义字符串选择一些值。以下是我的代码
$ this-> db-> from('posted');
$ st =infor ='rent'AND(typeq ='in'OR typeq ='out');
$ this-> db-> where($ st);
$ q = $ this-> db-> get();
发生数据库错误
错误号码:1054
未知列'infor ='rent''in'where子句'
SELECT * FROM `)WHERE`infor ='rent'` AND(typeq ='in'
OR typeq ='out')
文件名:C:\wamp\www\parklot\system\ database \DB_driver.php
行号:330
我认为问题是coz的
WHERE`infor ='rent'`
<$ c> $ c> WHERE infor ='rent'
如何摆脱
``
它会自动添加 $
$ <$> $ pwhere()
解决方案并设为FALSE
$ this-> db-> from('posted');
$ st =infor ='rent'AND(typeq ='in'OR typeq ='out');
$ this-> db->其中($ st,NULL,FALSE);
$ q = $ this-> db-> get();
Im trying to select some values using a custom string. below is my code
$this->db->from('posted'); $st="infor='rent' AND (typeq='in' OR typeq='out')"; $this->db->where($st); $q = $this->db->get();
A Database Error Occurred
Error Number: 1054 Unknown column ‘infor=‘rent’’ in ‘where clause’ SELECT * FROM (`posted_ads`) WHERE `infor=‘rent’` AND (typeq=‘in’ OR typeq=‘out’) Filename: C:\wamp\www\parklot\system\database\DB_driver.php Line Number: 330
i think the problem is coz of
WHERE `infor='rent'`
when i manualy execute this code it works perfectly.
WHERE infor='rent'
how do i get rid of
``
because its automatically added
解决方案Add a third parameter to the
where()
and set it to FALSE$this->db->from('posted'); $st="infor='rent' AND (typeq='in' OR typeq='out')"; $this->db->where($st, NULL, FALSE); $q = $this->db->get();
这篇关于codeigniter $ this-> db-> where();自定义字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文