Active Record join condition subquery escaped SELECT |
[eluser]Unknown[/eluser]
When I try to join with a subquery as a condition, the SELECT statement from that subquery is escaped what leads to a database error. Example : Code: $this->db->select('*'); Note that SELECT is the only word that is escaped from that subquery.
[eluser]Mark Croxton[/eluser]
This may help explain the problem with back ticks: https://gist.github.com/2923657
[eluser]Unknown[/eluser]
[quote author="Mark Croxton" date="1340437162"]This may help explain the problem with back ticks: https://gist.github.com/2923657[/quote] Thanks for bringing this issue to my attention, here's what I did : Edit file 'system/database/DB_active_rec.php' Modify function 'join', add a fourth parameter '$escape_cond' which will skip the condition identifiers protection when set to FALSE Code: public function join($table, $cond, $type = '', $escape_cond = TRUE) And join like this : Code: $this->db->join(t$able, $condition, '', FALSE); None of my other joins are impacted.
[eluser]Josepzin[/eluser]
HighKickX: good solution!! i do not like to modify the System files, but i do not understand why do not exist the $escape_cond param!
[eluser]Aken[/eluser]
All this does is circumvent the actual purpose of active record: to make writing simple queries easier and database-agnostic. If AR is limiting your ability to create more advanced queries, then I don't think you should be using AR in the first place. There's nothing wrong with using $this->db->query() with your own custom queries. |
Welcome Guest, Not a member yet? Register Sign In |