mcloan Posted November 1, 2006 Share Posted November 1, 2006 Can someone tell me in simple terms what is the difference between fetch_row() and fetch_object()?Thank you. Link to comment https://forums.phpfreaks.com/topic/25817-difference-between-fetch_row-and-fetch_object/ Share on other sites More sharing options...
trq Posted November 1, 2006 Share Posted November 1, 2006 One fetches a row as an array, the other as an object. Link to comment https://forums.phpfreaks.com/topic/25817-difference-between-fetch_row-and-fetch_object/#findComment-117888 Share on other sites More sharing options...
mcloan Posted November 1, 2006 Author Share Posted November 1, 2006 [quote author=thorpe link=topic=113475.msg461148#msg461148 date=1162394898]One fetches a row as an array, the other as an object.[/quote]Sorry, I am in the process of learning, can you provide an example of what the difference is between a row and object?Thank you. Link to comment https://forums.phpfreaks.com/topic/25817-difference-between-fetch_row-and-fetch_object/#findComment-117891 Share on other sites More sharing options...
trq Posted November 1, 2006 Share Posted November 1, 2006 They both return a row. One however is returned as a numeric array of database fields, the other as an object with each field as a property. You can also retrieve an associative array which is a little easier to work with IMO.eg;[code=php:0]// numeric array.$row = mysql_fetch_row($result);echo $row[0]; // prints the first field of the row.// associative array.$row = mysql_fetch_assoc($result);echo $row['id']; // prints the filed called id.// an object.$obj = mysql_fetch_object($result);echo $obj->id; // prints the field called id.[/code]If you dont know what an object is you probably don't need them just yet. You can read about them [url=http://php.net/oop]here[/url] though. Link to comment https://forums.phpfreaks.com/topic/25817-difference-between-fetch_row-and-fetch_object/#findComment-117897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.