CodeIgniter Forums
overzealous escaping active record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: overzealous escaping active record (/showthread.php?tid=12183)



overzealous escaping active record - El Forum - 10-09-2008

[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");



overzealous escaping active record - El Forum - 12-10-2008

[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?


overzealous escaping active record - El Forum - 12-10-2008

[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.


overzealous escaping active record - El Forum - 12-10-2008

[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.


overzealous escaping active record - El Forum - 12-10-2008

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