与 iSeries 的 ODBC 连接给出奇数个结果
我在 Ubuntu 8.04 LTS 上使用 UnixODBC 和 PHP 5.2.4,并尝试从 IBM i 上的表中提取所有结果并将它们复制到本地 MySQL 表。
从代码角度来说,它工作时没有错误,但我最终得到的行数比 IBM i 上包含的行数还要多。
我最终应该得到 25,613 行,但 PHP 报告有 25,630 行被插入到 MySQL 数据库中:
$counter = 0;
while($row = odbc_fetch_array($result)) {
//Insert into MySQL using Zend Framework
$counter++;
}
echo $counter;
当我查看 MySQL 数据库时,有些行实际上是重复的。 我在 odbc_fetch_array() 有关访问 IBM i 时不稳定行为的文档,但尝试该解决方案会导致脚本不断运行,似乎从未完成。
关于检查什么有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次都是重复相同的行吗? 如果是这样,这些记录是否有任何独特之处可以暗示它们为何重复?
也许使用另一个绑定来获取结果 - 例如 odbc_fetch_row()。
odbc_num_rows()
说什么?这些技术和其他技术可能会帮助您锁定错误。
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 doesodbc_num_rows()
say?These and other techniques might help you zone in on the bug.