Active records mixing querries |
[eluser]Sein Kraft[/eluser]
I'm needeing to get all the child categories from the given to use in a where_in with active records of codeigniter. The problem is that the second query get mixed with the main one breaking it completely. Main Query Code: $this->db->select('artworks.*, users.id as owner, users.name as user_name'); Second Query: get_categories(); Code: $this->db->select('*'); get_child_categories Code: function get_child_categories($categories, $parent){ But i'm getting this error where clearly displays that the second query is quetting inside the main one. Quote: Error Number: 1064
[eluser]Mikhail Menshinskiy[/eluser]
Yes, Active records mixing your queries and it's normally for your code. Look, you used an one object for SQL query - $this->db . So, here you start a FIRST sql query: Code: $this->db->select('artworks.*, users.id as owner, users.name as user_name'); Then, you call get_categories(): Code: $category = $this->get_child_categories($this->get_categories(), $matches[1]); Code: $this->db->select('artworks.*, users.id as owner, users.name as user_name'); And after that you try to continue a FIRST sql query, BUT this query has been already started and following code starts a SECOND sql query: Code: $this->db->where_in('artworks.category', $this->category['child']); To resolve your problem try to make this line the first: Code: $category = $this->get_child_categories($this->get_categories(), $matches[1]); So, your code should be: Code: $category = $this->get_child_categories($this->get_categories(), $matches[1]); Sorry for my English.
[eluser]Sein Kraft[/eluser]
Lol just a friend answered me this 9 minutes ago http://stackoverflow.com/questions/60096...ve-records Anyways...thank you so much! I didnt noticed this until he..and you, pointed this out. |
Welcome Guest, Not a member yet? Register Sign In |