Question

I'm using UnixODBC with PHP 5.2.4 on Ubuntu 8.04 LTS and trying to pull all the results from a table sitting on an IBM i and replicate them to a local MySQL table.

Code-wise it is working with no errors but I'm ending up with more rows that what is contained on the IBM i.

I should end up with 25,613 rows but PHP reports that 25,630 rows are being inserted into the MySQL database:

$counter = 0;
while($row = odbc_fetch_array($result)) {
    //Insert into MySQL using Zend Framework
    $counter++;
}
echo $counter;

When I look in the MySQL database some of the rows are actually duplicated. I saw a note on the odbc_fetch_array() documentation about erratic behavior when accessing the IBM i, but trying that solution causes the script to run and run without ever seeming to finish.

Any ideas on what to check?

Was it helpful?

Solution

Is it the same rows being duplicated each time? If so, is there anything unique about these records that could hint on why they are duplicated?

Perhaps use another binding for getting results -- like odbc_fetch_row(). What does odbc_num_rows() say?

These and other techniques might help you zone in on the bug.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top