Welcome Guest, Not a member yet? Register   Sign In
overzealous escaping active record
#1

[eluser]matt2012[/eluser]
I want to use active record to create a subquery join in the from call

however this syntax fails because CI escapes the `select` `from` etc.
setting select to false does not solve the problem as the query is not in the select
call.

Code:
$this->db->from("table1 LEFT JOIN
        ( select col1, col2
            from table2
            where  id = 13
        ) as table3
        ON table1.col1 = table3.col1");
#2

[eluser]Dan Herd[/eluser]
Why no replies to this?

Please can we have a 'false' second argument in the from() AR function so backticks are not added?
#3

[eluser]garrettheel[/eluser]
Why have you got the entire query in ->from() ? There are separate functions for joins and such. Check out the docs. If you use the functions properly, you wont have any troubles with backticks.
#4

[eluser]matt2012[/eluser]
If you look at the query it is a non standard join I think it would be a hard to replicate any other way but I may be wrong.

As for the original issue I think I solved it by messing with the from() class to give it a false argument.
#5

[eluser]garrettheel[/eluser]
If it's a complex query you might be better using $this->db->sql();




Theme © iAndrew 2016 - Forum software by © MyBB