Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-09-2009
Member
 
Join Date: Apr 2009
Posts: 69
How to implement function like fetch_object and the purpose of using it?

I have to use Array to 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? my another question to you is, why do we want to put them into "another" variable? the $row["field_name"]; if it is already a variable.
Reply With Quote
  #2  
Old 05-09-2009
Member
 
Join Date: Oct 2008
Posts: 117
Re: How to implement function like fetch_object and the purpose of using it?

Fetch array normally retrieves 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']

object maxdb_fetch_object ( object $result )

Object oriented style (method):
result
object fetch_object ( void )

One feature to assist you is the MySQLi class, which allows for an object-oriented approach to database manipulation. The maxdb_fetch_object() will return the current row result set as an object where the attributes of the object represent the names of the fields found within the result set. If no more rows exist in the current result set, NULL is returned.
Reply With Quote
  #3  
Old 05-09-2009
Member
 
Join Date: Mar 2008
Posts: 349
Re: How to implement function like fetch_object and the purpose of using it?

mysqli_result::fetch_object -- mysqli_fetch_object ? Returns the current row of a result set as an object. MySQLi stands for MySQL Improved, and is available from MySQL versions >= 4.1.3 and must be compiled in PHP with ?with-mysqli=/path/to/mysql/bin/mysql_config.

fetch_object will be implemented under the Object oriented style (method):

Code:
object mysqli_result::fetch_object  ([ string $class_name  [, array $params  ]] )
Reply With Quote
  #4  
Old 05-09-2009
Member
 
Join Date: Dec 2008
Posts: 202
Re: How to implement function like fetch_object and the purpose of using it?

So it's just a facility and not a burden on anybody. If you're following OOPs pattern then you may use mysql_fetch_object function otherwise get the processing done using mysql_fetch_assoc function. The mysqli_fetch_object() will return the current row result set as an object where the attributes of the object represent the names of the fields found within the result set.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to implement function like fetch_object and the purpose of using it?"
Thread Thread Starter Forum Replies Last Post
c# function equivalent to gettime function in javascript Omaar Software Development 4 10-03-2010 10:44 PM
Help me to implement the partition() function in the C++ language programming Gavyn Software Development 5 25-02-2010 03:35 PM
How does abstract function differs from virtual function? Maddox G Software Development 5 29-01-2010 11:32 AM
Purpose : Main( ) Function in C Fielder Software Development 4 27-01-2010 12:29 PM
How to implement the INITCAP equivalent function in SQL Server TechPredator Software Development 3 06-08-2009 03:33 PM


All times are GMT +5.5. The time now is 04:26 AM.