Odd behaviour with Active Record |
Hey guys,
for your information i'm using CI 3: Can anyone of you reproduce what i've experienced; I've a compound select query like: PHP Code: $query = $this->db Now, my problem is the generated Query Code: SELECT ur.*, ca.name, GROUP_CONCAT(ug.id SEPARATOR ', ') AS usergrouplist There is a space after the comma Am i overlooking something or is there a bug in CI ?
For too advanced queries I can suggest you to input normal query inline..
Code: $sql = "SELECT * FROM some_table WHERE id = ? AND status = ? AND author = ?"; Check here http://www.codeigniter.com/user_guide/da...eries.html Best VPS Hosting : Digital Ocean
Yeah you are right, i can do that, but i'm to lazy to write full queries
On the other hand, is this suggestion a recommendation or just a workaround for my problem because in my case the whole query looks like PHP Code: $query = $this->db And i really don't want to set aside the benefits of the Query Builder... (11-18-2014, 03:31 AM)sintakonte Wrote: Yeah you are right, i can do that, but i'm to lazy to write full queries You know that Query Builder is just a tool to generate correct query. So at the end you always get 1 line query.. At least from my experience if you have Big and Complicated query, its harder to use a Query Builder than to write it plain. So in some cases the better choice is a plain query.. In other cases where you have dynamic dependences QB is the best choice. Best VPS Hosting : Digital Ocean
@sintakonte
For this particular case you may try a temporary workaround about the bug for now. Use $this->db->get_compiled_select() method and see the generated $sql. Then, by using string search and replace on the $sql correct ', ' to ','. And then use $this->db->query($sql).
This problem results out of a core function inside the
Code: DB_query_builder.php Here you can search for the protected function Code: protected function _compile_select Code: $sql .= implode(', ', $this->qb_select); So here must be changed the space for the implode function. But - correct me if iam wrong - its not possible to extend the Database Classes without a deeper hack.
thx for your answers guys
PHP Code: $query = $this->db i tested the array solution and it works like a charm |
Welcome Guest, Not a member yet? Register Sign In |