$this->db->where('xx', $condition), CI会在$codition中的or关键字后面加空格
$condition='never or now';$this->db->select('*')->where('xx', $condition)->get('tablename')
echo $this->db->last_query(); //select * from tablename where xx = 'nerver ornow'; (or 和now中间有两个空格)
有解决方案吗?跟了一下代码发现是,DB_query_builder.php 中的function _compile_wh()导致的,里面有个正则
$conditions = preg_split(
'/((^|\s+)AND\s+|(^|\s+)OR\s+)/i',
$this->{$qb_key}[$i]['condition'],
-1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
); 结贴,问题已经有人解决了
issue #4093
https://github.com/bcit-ci/CodeIgniter/commit/554b452845e9ec26e1cd348fda607cf00d2a5026#diff-968a5c940a77faa7f3508a631b308ab3 应该是升级到 3.1.2 就解决了吧
页:
[1]