help cursors, odbc_connect, odbc_fetch_row

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I am using the odbc support in PHP 5.2 to connect to a sqlserver 2005

In the code below I  find that if I use SQL_CUR_USE_ODBC as an option
to odbc_connect, the odbc_fetch_row() call below fails even though the
odbc_exec was successful.

However, if I remove the SQL_CUR_USE_ODBC option the code executes

I have another query that uses some left outer joins on two tables and
am only able to read the results with odbc_fetch_row only if
SQL_CUR_USE_ODBC is used in odbc_conect.

How does one decide which cursor option to use?


$connect = odbc_connect("DB", "xx", "xxxx", SQL_CUR_USE_ODBC);
if (!$connect) {
    print("Connect failed.");
$query="SELECT TOP 1 Version FROM Versions ORDER BY VersionIndex
$result = odbc_exec($connect, $query);
if (!$result) {
   print(" Failed to execute $query.");
if (odbc_fetch_row($result)) {
   $data = odbc_result($result, 1);
   print("GOT data $data.");

Site Timeline