ads_result

Advantage PHP Extension

  Previous topic Next topic  

Retrieves the value of a field as a string.

Syntax

string ads_result( resource result_id,

string field )

OR

string ads_result( resource result_id,

int field )

Parameters

result_id (I)

ID of a result set.

field (I)

Name of the field in the result set.

or

field (I)

Number (position) of the field in the result set.

Remarks

ads_result retrieves the value of the specified field from the current row. The field can be identified in the result by either its name or position. The index of the first field of a result set is 1. In the event of an error, False is returned.

Example

<?

echo "Connecting to Server<br>\n";

$rConn = ads_connect( "DataDirectory=\\\\server1\\share1\\data\\;ServerTypes=2", "", "" );

echo "Connected<br>\n";

 

echo "Preparing a statement with a parameter<br>\n";

$rStmt = ads_prepare( $rConn, "SELECT * FROM customers WHERE company LIKE ?" );

echo "Statement prepared<br>\n";

 

echo "Executing the statement. Notice the array of parameters<br>\n";

$aParams = array( 1 => 'A%' );

$rResult = ads_execute( $rStmt, $aParams );

echo "Execution was successful<br>\n";

 

echo "Retrieve the Company Name and Credit Limit<br>\n";

while ( ads_fetch_row( $rStmt ) )

{

$strCompanyName = ads_result( $rStmt, "COMPANY" );

$strCreditLimit = ads_result( $rStmt, "CREDIT_LIMIT" );

echo $strCompanyName . " can spend up to $" . $strCreditLimit . "<br>\n";

}

 

echo "Closing the connection<br>\n";

ads_close( $rConn );

echo "Disconnected<br>\n";

?>

See Also

ads_execute

ads_exec

ads_do

ads_field_len