![]() |
How can I get stdClass Object instead of an array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How can I get stdClass Object instead of an array (/showthread.php?tid=30442) |
How can I get stdClass Object instead of an array - El Forum - 05-14-2010 [eluser]DaTran[/eluser] I have the basics of passing an array of $data into the view thus turning them into objects to echo. But im having trouble getting my array to come out like my working tutorial samples. So my question is how can I get a stdClass Object array instead of a normal array This is my print_r() of the two, maybe it'll give you a better understanding of my suffering. The working Code: Array Non working Code: Array This is my controller function for both of them: Code: function index() and as you would expect a simple snippet of my viewing: Code: <?php foreach($records as $row): ?> Finally the problem the model page: Code: $query = $this->db->get('auction'); Sorry for so much code, im very new so please be kind. How can I get stdClass Object instead of an array - El Forum - 05-14-2010 [eluser]Aken[/eluser] Code: $query = $this->db->get('auction'); You should also learn about SQL JOIN commands, which would allow you to attach the item name to the first query, and not need to run a second query inside each loop iteration. I could've written the code for you, but where's the fun in that? ![]() How can I get stdClass Object instead of an array - El Forum - 05-14-2010 [eluser]DaTran[/eluser] Wow that was amazing!!! thank you, and thanks in advance for giving me a new topic to learn. How can I get stdClass Object instead of an array - El Forum - 05-14-2010 [eluser]pickupman[/eluser] Code: $this->db->select('auction.*, items.name'); //all columns in auction table and name from items table |