Adding property to an object - 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: Adding property to an object (/showthread.php?tid=16765) |
Adding property to an object - El Forum - 03-16-2009 [eluser]Marcelo Kanzaki[/eluser] Sorry, i don't know if this is the right place to ask this. But i really could use some help. I'm using CI with PHP5 and when i went testing on the server, some bugs happened. I have this function in on of my models and i didn't know that php4 doesn't support adding properties to objects the way i did. Can someone tell me how to get around this problem? Code: function find_ ($page_id) Adding property to an object - El Forum - 03-16-2009 [eluser]Phil Sturgeon[/eluser] Code: function find_ ($page_id) Notice the & before the $row in your foreach. This means the $row is passed by refference and not by value, meaning you can modify that variable and change the original value. Adding property to an object - El Forum - 03-16-2009 [eluser]xwero[/eluser] You need to not only bind the new property to the row but you have to bind it to the array too. Code: $rows = $query->result(); Adding property to an object - El Forum - 03-16-2009 [eluser]Marcelo Kanzaki[/eluser] Thank you both so much for the fast and helpful reply. Problem solved. |