Topic
  • 1 reply
  • Latest Post - ‏2009-06-13T02:10:29Z by ishields
SystemAdmin
SystemAdmin
2364 Posts

Pinned topic Data corruption using ODBC_Connect in PHP accessing a DB2 database

‏2009-06-12T19:48:21Z |
I have a program written in PHP on a Linux system. I am running a query that retrieves all the records from a table in a DB2 database running on an IBM iSeries server. I am using ODBC_Connect to get the data. The driver is IBM DB2 ODBC Driver v2.2.12. Around 94,000 records are being returned in the query with 15 being displayed on a page at a time. The data is being displayed in a table with basic info from each record. When I have more than 32,767 records the 32,767th record begins replacing every other row after it is displayed in the table. For example. I have the following records: recordid = 32765, name=client 765; recordid = 32766, name=client 766; recordid 32767, name client 767; recordid 32768, name client 768; recordid 32769, name client 769; etc. When they are displayed in the table you will have:
Record ID Name
32765 Client 765
32766 Client 766
32767 Client 767
32768 Client 768
32767 Client 767
32770 Client 770
32767 Client 767

You'll notice that record #s 32769 abd 32771 are not displayed, 32767 has replaced them. This will continue for every other succeeding row in the result set. Every other row in the result set is replaced with the data for record 32767.

I am using the following PHP code to get at the records. xx is incremented by 15 each sucessive page that is called and $rowNum specifies at which record number to begin showing the results on the page:
sqlQuery = “SELECT * FROM UserTable”;
sqlQuery .= " FETCH FIRST xx ROWS ONLY";
$resultset = odbc_exec($odbcConn, $sqlQuery);
while ($row = odbc_fetch_array($resultset, $rowNum)){
displayRowAssoc($row);
$rowNum++;
}

Does anyone know if this could be a problem with ODBC, PHP, DB2, a combination of the 3....? I have done exhaustive searches on Google to no avail. I hope someone here can help me.
Updated on 2009-06-13T02:10:29Z at 2009-06-13T02:10:29Z by ishields
  • ishields
    ishields
    988 Posts

    Re: Data corruption using ODBC_Connect in PHP accessing a DB2 database

    ‏2009-06-13T02:10:29Z  
    I'd say something on the path is limited to 2^15-1=32767.

    Ian Shields
    Updated on 2009-06-13T02:10:29Z at 2009-06-13T02:10:29Z by ishields