Welcome Guest, Not a member yet? Register   Sign In
error escaping variables with backtips in select option with active record
#1

[eluser]Unknown[/eluser]
Hi everybody!

I've produced a query using active record with a select statement like this:

Code:
$this->db->select("pm.*, pmo2.entity_id as owner_id, pmo2.type as owner_type, CONCAT(u.name, ' ', u.surname ) as owner_name, ids.entity as owner_entity")

but after the get call the query produced has a select statement like these one:

Code:
SELECT `pm`.*, `pmo2`.`entity_id` as owner_id, `pmo2`.`type` as owner_type, CONCAT(u.name, `'` ', `u`.`surname` ) as owner_name, `ids`.`entity` as owner_entity

the space char in the CONCAT is not correctly escaped and generates an execution error...

is this a bug?

Sorry for my bad english and thanks for this wonderful framework! I love it!
#2

[eluser]Trippo[/eluser]
i have the same problem.... how can i solve this problem?
#3

[eluser]Trippo[/eluser]
[quote author="etilico" date="1243619568"]Hi everybody!

I've produced a query using active record with a select statement like this:

Code:
$this->db->select("pm.*, pmo2.entity_id as owner_id, pmo2.type as owner_type, CONCAT(u.name, ' ', u.surname ) as owner_name, ids.entity as owner_entity")

but after the get call the query produced has a select statement like these one:

Code:
SELECT `pm`.*, `pmo2`.`entity_id` as owner_id, `pmo2`.`type` as owner_type, CONCAT(u.name, `'` ', `u`.`surname` ) as owner_name, `ids`.`entity` as owner_entity

the space char in the CONCAT is not correctly escaped and generates an execution error...
[/quote]

I find the solution....
It's simple, you place as second parameter of select function FALSE:
Code:
$this->db->select("pm.*, pmo2.entity_id as owner_id, pmo2.type as owner_type, CONCAT(u.name, ' ', u.surname ) as owner_name, ids.entity as owner_entity",FALSE)




Theme © iAndrew 2016 - Forum software by © MyBB