PHP ODBC and Pervasive.SQL
| From: | Pascal Schaedeli | Date: | Thu, 26 Feb 2004 02:42:38 +0000 |
| Subject: | PHP ODBC and Pervasive.SQL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-178952@lists.php.net to get a copy of this message | ||
Hi,
I am executing a SELECT query from PHP (4.3.4) through ODBC on a Pervasive
2000SP4 (all on Windows). odbc_result_all, odbc_fetch_into, and all other
php odbc function stop returning records before the end of the effective
resultset.
Here is what is happening :
* In Pervasive: SELECT * FROM table returns n records (correct).
* In Access, throught ODBC, the same query returns the same n records
(correct).
* In PHP, odbc_exec of the same query returns m<n records.
Specifically, I have identifed one field (call it fieldx) that seems to be
at the source of the problem : it seems stored over 4 bytes in Pervasive and
represents a decimal number.
If I rewrite the query in PHP to read SELECT fielda, fieldb,fieldc FROM
table, it returns n records (correct) (just to clarify SELECT fielda,
fieldb,fieldc,fieldx FROM table returns m<n records).
How many is m? It depends on the sort order. I have identified with record's
fieldx is causing the problem. The records returned by odbc_* are up to that
problem record. If the sort order makes that problem record to be the last
one, then m = n-1. If the sort order makes that record be the first, then m
= 0.
Here is even more details for those who are still reading:
fieldx is written to Pervasive from an application for which I do not have
the source code. If I read the content of fieldx of the problem records,
erase it and manually re-enter it (in Pervasive Control Center), the issue
is solved and the PHP odbc query returns n records.
I'm not an expert on odbc and pervasive. Intuitively, it seems that the
field is somehow missformated. However, both Pervasive and Access are able
to interpret it correctly.
Does anybody have a suggestion on how I could either:
- Get Pervasive to reformat all field correctly.
- Get the odbc library in PHP to at least give me an error, or better,
interpret the field as Access does.
Thanks,
Pascal