Welcome Guest, Not a member yet? Register   Sign In
Active Record: fields from formula-Problem
#1

[eluser]Ornis[/eluser]
I want to run the following mysql query:

SELECT
id,
CONCAT(number," ", species)
FROM
table

If I use active record:

$fields = "id, CONCAT(number,\" \", species)";
$this->db->select($fields);


I run into an error, because Codeignter inserts high-comma within the statement. Is their a workaround for this problem?

Thanks Martin
#2

[eluser]davidbehler[/eluser]
Code:
$this->db->select('id');
$this->db->select("CONCAT(number, ' ', species)", FALSE);

CI tries to protect table/column identifiers, that's what causes the high-comma.
By passing FALSE as second parameter you can disable this feature.
#3

[eluser]Ornis[/eluser]
Thanks. It works well this way.
#4

[eluser]mineass[/eluser]
by passing FALSE you disable protect_identifiers for whole query and not only this select line




Theme © iAndrew 2016 - Forum software by © MyBB