![]() |
Convert object value to int ? - 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: Convert object value to int ? (/showthread.php?tid=10883) |
Convert object value to int ? - El Forum - 08-17-2008 [eluser]Berserk[/eluser] hi there, i'm a php newbie and i'm writing an small app using CI but i get some err. myDB post: Code: post_id cat: Code: id At my model, i created function get_viewed and get_max_view Code: function get_viewed($id) Code: function get_max_viewed($id) my controller Code: $maxview = $this->details->get_max_viewed($catid) my view: Code: <?php but i got error, system said cannot convert $maxview from object to int. How to fix this problem ? Convert object value to int ? - El Forum - 08-17-2008 [eluser]gon[/eluser] $maxview is an object, containing 2 properties: 'viewed' and 'maxviewed'. Use the appropiate one to do the calculation. Strangely, you do that correctly with $post, but not with $maxview. Convert object value to int ? - El Forum - 08-17-2008 [eluser]Berserk[/eluser] thanks, fixed this problem. i forgot about properties ![]() |