GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Programming  >  PHP
Go To First  |  Previous Question  |  Next Question 
 PHP  |  Question 60 of 62    Print  
why we need a function like fetch_object and what is the purpose of using it?
we have fetch_array to fetch a row from a result set... in what way the fetch_object function is useful... at which situation it is used? every question is like what is the difference and the answers is just like the following 'fetch_array" gives an array of any type but fetch_object will return an object.... but WHY???


  
Total Answers and Comments: 3 Last Update: November 04, 2008     Asked by: jachmullan 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: aschandra27
 
Fetch array normally retrives the records based on array index. i.e. like $row[1], but if you want to retrieve the record based on the column name we can use fetch_object i.e. $row['username']

Above answer was rated as good by the following members:
rashope
September 09, 2008 09:59:02   #1  
aschandra27 Member Since: March 2008   Contribution: 1    

RE: why we need a function like fetch_object and what is the purpose of using it?
Fetch array normally retrives the records based on array index. i.e. like $row[1], but if you want to retrieve the record based on the column name we can use fetch_object i.e. $row['username']
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
September 17, 2008 01:18:41   #2  
mohit_php Member Since: August 2008   Contribution: 1    

RE: why we need a function like fetch_object and what is the purpose of using it?
just read this script and you will be get cleared
<?php
mysql_connect
("hostname""user""password");
mysql_select_db("mydb");
$result mysql_query("select * from mytable");
while (
$row mysql_fetch_object($result)) {
    echo 
$row->user_id;
    echo 
$row->fullname;
}
mysql_free_result($result);
?>

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
November 04, 2008 00:51:01   #3  
jaya4jaya Member Since: June 2008   Contribution: 1    

RE: why we need a function like fetch_object and what is the purpose of using it?

Fetch a result row as a combination of associative array and regular array.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape