IgnitedRecord 1.0 pre-release - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: IgnitedRecord 1.0 pre-release (/showthread.php?tid=7996) |
IgnitedRecord 1.0 pre-release - El Forum - 11-24-2008 [eluser]m4rw3r[/eluser] What you can do is to use the dbobj2orm() method of IR_base (which means that all models extending IgnitedRecord has it) to convert an object of db_result into IR_records (or whatever class is specified). To easily make a query to the database, create an instance of IgnitedQuery, it is IR's replacement of ActiveRecord and is made as a stand alone lib too (I've just made IR_base extend IgnitedQuery to get the SQL building methods). Example usage: Code: // in the model: IgnitedRecord 1.0 pre-release - El Forum - 11-24-2008 [eluser]dcunited08[/eluser] Code: $this->select(array('ThicknessNameOut', 'WidthNameOut', 'LengthNameIn')); This worked in 0.2.0 but fails, as you described, in 1.0 because there is a Code: $this->select($this->table.'*'); IgnitedRecord 1.0 pre-release - El Forum - 11-25-2008 [eluser]m4rw3r[/eluser] The reason I have this code: Code: $this->select($this->table.'*'); Actually, if you want to call the IgnitedQuery::get() from the IgnitedRecord class, you should be able to call it as a static method: Code: function foo() IgnitedRecord 1.0 pre-release - El Forum - 11-25-2008 [eluser]dcunited08[/eluser] Excellent, thank you very much! IgnitedRecord 1.0 pre-release - El Forum - 11-25-2008 [eluser]voland[/eluser] Hi. find_by_sql and find_all_by_sql doesnt work. Message: Undefined property: User::$db Filename: ignitedrecord/ignitedrecord.php Line Number: 869 I think $this->db - doesnt exists). IgnitedRecord 1.0 pre-release - El Forum - 11-26-2008 [eluser]m4rw3r[/eluser] Thanks! Corrected it (the db property isn't needed, but I overlooked those methods when I removed $this->db). IgnitedRecord 1.0 pre-release - El Forum - 11-30-2008 [eluser]cayasso[/eluser] I am trying to use CI Template Parser library(only accepts arrays) and IgnitedRecord library to pass the data using for example; But I need for this to work I would need to be able get the result from IgnitedRecord as an array and not an object, I am unable to figure out a good way to do this can any one help me out. Model Code: class Contents extends IgnitedRecord{ Controller Code: class Content extends Controller{ View Code: {content} Is there a way i can go around this, if there is can you help me out with an example I will really appreciate it. This is the error I get Code: A PHP Error was encountered Thank you!! IgnitedRecord 1.0 pre-release - El Forum - 11-30-2008 [eluser]sophistry[/eluser] quick, but not tested... does this help? Code: $data['content'] = (array)$this->content_mod->find_all(); IgnitedRecord 1.0 pre-release - El Forum - 11-30-2008 [eluser]cayasso[/eluser] Thanks sophistry but I got the same error!!! IgnitedRecord 1.0 pre-release - El Forum - 12-01-2008 [eluser]m4rw3r[/eluser] The problem there is that the type-casting isn't recursive, and you'll end up with an array of objects (which it already was). You need to make it recursive (and also to ignore properties like __instance). I'm currently at school, so I'll post something when I get home. |