在SELECT字段列表CONCAT()函数 [英] CONCAT() function in a SELECT field list

查看:2066
本文介绍了在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.

这篇关于在SELECT字段列表CONCAT()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆