Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : ODBC Functions (Unified) : odbc_next_result

odbc_next_result

Checks if multiple results are available (PHP 4 >= 4.0.5, PHP 5)
bool odbc_next_result ( resource result_id )

Example 1662. odbc_next_result()

<?php
$r_Connection
= odbc_connect($dsn, $username, $password);

$s_SQL = <<<END_SQL
SELECT 'A'
SELECT 'B'
SELECT 'C'
END_SQL;

$r_Results = odbc_exec($r_Connection, $s_SQL);

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"Dump first result set";
var_dump($a_Row1, $a_Row2);

echo
"Get second results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"Dump second result set ";
var_dump($a_Row1, $a_Row2);

echo
"Get third results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"Dump third result set ";
var_dump($a_Row1, $a_Row2);

echo
"Try for a fourth result set ";
var_dump(odbc_next_result($r_Results));
?>

The above example will output:

Dump first result set array(1) {
 ["A"]=>
 string(1) "A"
}
bool(false)
Get second results set bool(true)
Dump second result set array(1) {
 ["B"]=>
 string(1) "B"
}
bool(false)
Get third results set bool(true)
Dump third result set array(1) {
 ["C"]=>
 string(1) "C"
}
bool(false)
Try for a fourth result set bool(false)
Examples ( Source code ) » odbc_next_result

<?php
$r_Connection 
odbc_connect($dsn$username$password);

$s_SQL = <<<END_SQL
SELECT 'A'
SELECT 'B'
SELECT 'C'
END_SQL;

$r_Results odbc_exec($r_Connection$s_SQL);

$a_Row1 odbc_fetch_array($r_Results);
$a_Row2 odbc_fetch_array($r_Results);
echo 
"Dump first result set";
var_dump($a_Row1$a_Row2);

echo 
"Get second results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 odbc_fetch_array($r_Results);
$a_Row2 odbc_fetch_array($r_Results);
echo 
"Dump second result set ";
var_dump($a_Row1$a_Row2);

echo 
"Get third results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 odbc_fetch_array($r_Results);
$a_Row2 odbc_fetch_array($r_Results);
echo 
"Dump third result set ";
var_dump($a_Row1$a_Row2);

echo 
"Try for a fourth result set ";
var_dump(odbc_next_result($r_Results));
?>

The above example will output:

Dump first result set array(1) {
  ["A"]=>
  string(1) "A"
}
bool(false)
Get second results set bool(true)
Dump second result set array(1) {
  ["B"]=>
  string(1) "B"
}
bool(false)
Get third results set bool(true)
Dump third result set array(1) {
  ["C"]=>
  string(1) "C"
}
bool(false)
Try for a fourth result set bool(false)


    

Code Examples / Notes » odbc_next_result

mypsuedoemail

This function works exactly like its equivalent Microsoft SQL Server function: mssql_next_result(). The information above is rather vague and a bit misleading, so refer to the mssql version of this function for details on to use it properly.
P.S. It works with stored procedures.


ryanphp

Running this on a MS Access result set always seems to return false. It may have the same driver limitations as odbc_num_rows.

Change Language


Follow Navioo On Twitter
odbc_autocommit
odbc_binmode
odbc_close_all
odbc_close
odbc_columnprivileges
odbc_columns
odbc_commit
odbc_connect
odbc_cursor
odbc_data_source
odbc_do
odbc_error
odbc_errormsg
odbc_exec
odbc_execute
odbc_fetch_array
odbc_fetch_into
odbc_fetch_object
odbc_fetch_row
odbc_field_len
odbc_field_name
odbc_field_num
odbc_field_precision
odbc_field_scale
odbc_field_type
odbc_foreignkeys
odbc_free_result
odbc_gettypeinfo
odbc_longreadlen
odbc_next_result
odbc_num_fields
odbc_num_rows
odbc_pconnect
odbc_prepare
odbc_primarykeys
odbc_procedurecolumns
odbc_procedures
odbc_result_all
odbc_result
odbc_rollback
odbc_setoption
odbc_specialcolumns
odbc_statistics
odbc_tableprivileges
odbc_tables
eXTReMe Tracker