clear 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: clear active record (/showthread.php?tid=36767) Pages:
1
2
|
clear active record - El Forum - 12-14-2010 [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.)? clear active record - El Forum - 12-14-2010 [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-guide/database/active_record.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. clear active record - El Forum - 12-14-2010 [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? clear active record - El Forum - 12-14-2010 [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-guide/database/active_record.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? clear active record - El Forum - 12-14-2010 [eluser]Clifford James[/eluser] Here an example: Code: $this->db->select('contact.*'); clear active record - El Forum - 12-14-2010 [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? clear active record - El Forum - 12-14-2010 [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. clear active record - El Forum - 12-14-2010 [eluser]Clifford James[/eluser] Problem solved. Moved the ->select() lower in the ORM method. clear active record - El Forum - 12-14-2010 [eluser]Cesar Kohl[/eluser] I see I couln't help you much but, anyway, you solved the problem! clear active record - El Forum - 12-14-2010 [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! |