Collections:
Returning Result from Query with ODBC Connection
How To Receive Returning Result from a Query?
✍: Guest
When you execute a SQL SELECT statement with the odbc_exec() function, you can capture the returning result with a result set object with the following syntax:
$result_set = odbc_exec($sql_statement); #- The returning value could be a Boolean value FALSE, #- if the execution failed.
Data rows and field values in the result set object can be retrieved using other ODBC functions as shown in the tutorial PHP script below:
<?php
$con = odbc_connect('FYI_SQL_SERVER','sa','FYIcenter');
$sql = 'SELECT GETDATE()';
$res = odbc_exec($con, $sql);
odbc_fetch_row($res);
$date = odbc_result($res,1);
print("Database current time: ". $date ."\n");
odbc_close($con);
?>
If you run this script, you will get something like this:
Database current time: 2007-06-02 22:07:05.110
⇒ odbc_fetch_row() - Looping through Result Set Objects
⇐ Turning Off PHP Warning Messages for ODBC Connection
⇑ SQL Server FAQs - PHP ODBC Functions - Connection and Query Execution
2024-07-17, 2298🔥, 1💬
Popular Posts:
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
What Is Oracle in Oracle? Oracle is a company. Oracle is also a database server, which manages data ...
How To Revise and Re-Run the Last SQL Command in Oracle? If executed a long SQL statement, found a m...
How To Generate CREATE TABLE Script on an Existing Table in SQL Server? If you want to know how an e...
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...