clear active record |
[eluser]Clifford James[/eluser]
I'm building an ORM for CI using CI's Active Record. In a few methods I'm using $this->db->select('table.*'); but this gives an error while working with multiple relations in one action (cleaning up relations after one is deleted). The problem is that $this->db->select() is called multiple times and my query looks like this: SELECT `contacts`.*, `contacts`.*, `orders`.* FROM (`orders`) WHERE `orders`.`customer_id` = 3 How can I clear previous Active Record settings (e.g. table, where, join etc.)?
[eluser]Cesar Kohl[/eluser]
To load everything on a table, use this code: Code: $query = $this->db->get('mytable'); Read the User Guide to have more information: http://ellislab.com/codeigniter/user-gui...ecord.html You need to put the query in different strings: Code: $author = 'Cesar'; At least is what I do and I never had your problem.
[eluser]Clifford James[/eluser]
Removed the ->select('table.*') works for now, but it's weird it is used again after ->get() , ->result() , ->row() , etc don't you agree?
[eluser]Clifford James[/eluser]
[quote author="Cesar Kohl" date="1292354773"]To load everything on a table, use this code: Code: $query = $this->db->get('mytable'); Read the User Guide to have more information: http://ellislab.com/codeigniter/user-gui...ecord.html You need to put the query in different strings: Code: $author = 'Cesar'; At least is what I do and I never had your problem.[/quote] What do you see in the queries section in the profiler after these queries?
[eluser]Clifford James[/eluser]
Here an example: Code: $this->db->select('contact.*');
[eluser]Cesar Kohl[/eluser]
I didn't understand your example, so I'll use another one: Code in controller: Code: //Assume there is a table with 4 rows: id, phrase, tags, id_author Output in browser: Quote:Array Any questions?
[eluser]Clifford James[/eluser]
The example is what my queries look like in the profiler, but in my orm I don't store the results in an array but I just return them.
[eluser]Clifford James[/eluser]
Problem solved. Moved the ->select() lower in the ORM method.
[eluser]Cesar Kohl[/eluser]
I see I couln't help you much but, anyway, you solved the problem!
[eluser]Clifford James[/eluser]
[quote author="Cesar Kohl" date="1292363183"]I see I couln't help you much but, anyway, you solved the problem![/quote] Thanks for your time! |
Welcome Guest, Not a member yet? Register Sign In |