Prepares and executes an SQL statement.
Syntax
resource ads_exec( int connection_id, string query )
Parameters
connection_id (I) |
ID of a connection to the Advantage Database Server. |
query (I) |
The SQL statement to be executed. |
Remarks
ads_exec is a combination of ads_prepare and ads_execute. The SQL statement executed via ads_exec cannot have parameters. If parameters are required, use ads_prepare and ads_execute.
When executing a successful SELECT statement or EXECUTE statement with a result set, a result set identifier will be returned. This result set identifier can be used to retrieve values from the result set.
Example
<?
echo "Connecting to Server<br>\n";
$rConn = ads_connect( "DataDirectory=\\\\server1\\share1\\data\\;ServerTypes=2", "", "" );
echo "Connected<br>\n";
echo "Executing a statement<br>\n";
$rResult = ads_exec( $rConn, "SELECT SUM( amount ) as Total FROM orders" );
echo "Statement executed<br>\n";
echo "Getting the cursor name<br>\n";
$sName = ads_cursor( $rResult );
echo "The cursor is named: " . $sName . "<br>\n";
echo "Closing the connection<br>\n";
ads_close( $rConn );
echo "Disconnected<br>\n";
?>
See Also