Well - here's an odd one:

PHP 4.2.1 (win32)
apache 1.3.26
W2K Workstation

Making an ODBC Connection to a DB2 database, everything is working with the 
sole exception that it never ever returns any rows.  The correct number of 
fields are being returned each time, even when the query absolutely requires a 
row to be returned. 

Code
<?php
class fetch_object
{
        function fetch( $re )
        {
                if( !$re )
                        return null;
                
                $no_f = odbc_num_fields( $re );
                if( odbc_fetch_row( $re ) )
                {
                        for( $i = 1; $i <= $no_f; $i++ )
                        {
                                $fn = odbc_field_name( $re, $i );
                                $f_re = odbc_result( $re, $i );
                                $ff = "\$this->$fn = \"" . addslashes( $f_re ) .
"\";";
                                eval( $ff );
                        }
                }
                else
                        return null;
        }
}

function odbc_fetch_object( $result )
{
        $good = new fetch_object;
        $good->fetch( $result );
        return $good;
}



$dbconn = odbc_connect ( "DSN", "USER", "PASSWORD");

echo "Connected to: $dbconn<br>";
# $sqlresult = odbc_exec( $dbconn, "SELECT ATTR_NM, NEW_VALUE FROM RU99.RC548 
WHERE SIGNONID = 'L6XJ'");
$sqlresult = odbc_exec( $dbconn, "SELECT COUNT(*) AS TOTAL FROM RU99.RC545 
WHERE SIGNONID='L6XJ'");
echo $sqlresult . "<BR>";

$mycursor = odbc_cursor ( $sqlresult);
echo $mycursor . "<BR>";

echo "Fields: " . odbc_num_fields ($sqlresult);
echo "Rows: " . odbc_num_rows ($sqlresult);

while ($row = odbc_fetch_object ($sqlresult) ) {
        echo $row->ATTR_NM . "<BR>" ;
        echo $row->NEW_VALUE . "<BR>";
}

odbc_close($dbconn);

?>

Output:
Connected to: Resource id #1
Resource id #2
SQLLF0004
Fields: 1 Rows: 0


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to