I am trying to fetch the records from the sybase view ODBC in PHP but it does not return data. I am getting records from table but not able to get data from view.
Query -- select * from odb.VP_myview;
odb = odbc DSN
VP_myview = view
Above query does not show any error but same time it does not return any records.
Below is PHP code
<?php
$con = @odbc_connect('DSN','USERNAME','PASSWORD',SQL_CUR_USE_ODBC) or die("<B>Error!</B> Couldn't Connect To Database. Error Code: ".odbc_error());
$query = 'select * from odb.VP_myview';
$result = odbc_exec($con,$query);
$totrec = odbc_num_rows($result);
var_dump($totrec);// it return negative integer number
exit;
?>
It would be really great help. I am trying since last 3-4 days but no success.
From the manual:
Using odbc_num_rows() to determine the number of rows available after a SELECT will return -1 with many drivers.
That's especially true for Sybase. C.f. this question