在SELECT字段列表CONCAT()函数
我用codeIgniter的活动记录的功能,但我不能选择我感兴趣的数据。
I'm using CodeIgniter's active record features but I'm not able to select the data I'm interested in.
我想选择是:
CONCAT(t.field1, ' / ', t.field2) AS `finalValue`
所以,我补充一点:
So I add this:
$this->db->select('CONCAT(t.field1, \' / \', t.field2) AS `finalValue`');
不过,这就是会产生的查询字符串:
But this is the query string that's generated:
CONCAT(t.field1, `'` / ', `t`.`field2)` AS `finalValue`
这是一个错误?我是否指定它不正确?
Is this a bug? Am I specifying it incorrectly?
实际上,你可以关闭默认逃逸机制,这是一个奇怪的问题,使用MySQL的功能,当源,通过传递FALSE作为第二个参数中选择'方法。
You can actually turn off the default escaping mechanism, which is the source of a strange issue when using MySQL functions, by passing FALSE as the second parameter of 'select' method.
请注意,您必须再处理逃脱自己,如果你做到这一点。
Be aware that you must then handle escaping yourself if you do this.
哦,你可以使用双引号,以减少所有逃避你怎么回事。
Oh, and you could use double quotes to reduce all that escaping you have going on.