Xtremer360 Posted November 8, 2012 Share Posted November 8, 2012 The question I have is if you notice with the line below its supposed to get the status name of the title. However in the get_title_statuses function it returns an object so I’m trying to figure out how when I need only a certain value of one of the keys in the object I can just return the value. [color=#000000][color=#0000BB]$titles [/color][color=#007700]= [/color][color=#0000BB]$this[/color][color=#007700]->[/color][color=#0000BB]titles_model[/color][color=#007700]->[/color][color=#0000BB]get_titles[/color][color=#007700](array([/color][color=#DD0000]'title_status' [/color][color=#007700]=> array([/color][color=#0000BB]1[/color][color=#007700],[/color][color=#0000BB]2[/color][color=#007700],[/color][color=#0000BB]3[/color][color=#007700]))); for([/color][color=#0000BB]$x [/color][color=#007700]= [/color][color=#0000BB]0[/color][color=#007700]; [/color][color=#0000BB]$x [/color][color=#007700]< [/color][color=#0000BB]count[/color][color=#007700]([/color][color=#0000BB]$titles[/color][color=#007700]); [/color][color=#0000BB]$x[/color][color=#007700]++)[/color] [color=#0000BB]{ $titles[$x][/color][color=#007700]->[/color][color=#0000BB]title_status_name [/color][color=#007700]= [/color][color=#0000BB]$this[/color][color=#007700]->[/color][color=#0000BB]titles_model[/color][color=#007700]->[/color][color=#0000BB]get_title_statuses[/color][color=#007700](array([/color][color=#DD0000]'titles' [/color][color=#007700]=> [/color][color=#0000BB]$titles[$x][/color][color=#007700]->[/color][color=#0000BB]title_status_id[/color][color=#007700])); [/color] [color=#0000BB]} [/color] [/color] Here's a link to what I have for my model functions. I had to include it in a separate place. http://pastebin.com/h6XZvr4s Link to comment https://forums.phpfreaks.com/topic/270465-returning-just-a-row-value-instead-of-object/ Share on other sites More sharing options...
requinix Posted November 8, 2012 Share Posted November 8, 2012 If anyone's wondering, $titles = $this->titles_model->get_titles(array('title_status' => array(1,2,3))); for($x = 0; $x < count($titles); $x++) { $titles[$x]->title_status_name = $this->titles_model->get_title_statuses(array('titles' => $titles[$x]->title_status_id)); } If you just need one of the members of the object then just get that one member and discard the rest. Link to comment https://forums.phpfreaks.com/topic/270465-returning-just-a-row-value-instead-of-object/#findComment-1391118 Share on other sites More sharing options...
Xtremer360 Posted November 8, 2012 Author Share Posted November 8, 2012 I have no idea how my post code showed up like that but thank you. Were you able to take a look at the controller code. Working with OOP is nice but here's a situation where with the class function and its possible parameters I need it to get a row value or a whole row or whole object and I'm not sure what I can do right now to account for that? And each situation is pretty much based on what parameters there are. Link to comment https://forums.phpfreaks.com/topic/270465-returning-just-a-row-value-instead-of-object/#findComment-1391135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.