PHP | odbc_fetch_object() Function

PHP odbc_fetch_object() Function


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP odbc_fetch_object() Function.

The odbc_fetch_object() function fetches a result as an object.

Syntax

Following below is the syntax to use this function -

object odbc_fetch_object ( resource $result [, int $rownumber ] )


Parameter Details

Sr.NoParameters & Description
1

result

It contains result resources from odbc_exec()

2

rownumber

we can choose optionally that which number of row to retrive


Return Value

This built-in PHP function returns an object on success or otherwise sends a message as there is no more rows.

Example

Try out the following example below -

<?php
   $input_ID = odbc_connect($db_name, $username, $password) or die(odbc_error_msg());
   $sql = "SELECT * FROM TABLE";
   $result = odbc_exec($input_ID, $sql);
   
   while ($rows = odbc_fetch_object($result)) {
      print $rows->COLUMNNAME;
   }
   
   odbc_close($input_ID); 
?>


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP odbc_fetch_row() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.

Thanks for reading and bye for now.