[英]InnoDB insert fails silently, works fine when table is MyISAM
I've got an InnoDB table in MySQL 5.0.77 that looks like this:我在 MySQL 5.0.77 中有一个 InnoDB 表,如下所示:
CREATE TABLE `products_vendors` (
`vendor_id` int(10) unsigned NOT NULL,
`product_id` int(10) unsigned NOT NULL,
`original_quantity` smallint(6) unsigned NOT NULL,
`quantity` smallint(5) unsigned NOT NULL,
`price` decimal(19,8) NOT NULL,
`created` int(10) unsigned NOT NULL,
`valid_until` int(10) unsigned NOT NULL,
PRIMARY KEY (`vendor_id`,`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I'm using PHP and PDO to perform an insert.我正在使用 PHP 和 PDO 执行插入。 When the code is executed, the insert fails silently.
执行代码时,插入会静默失败。 But, if I change the table from InnoDB to MyISAM, everything works fine.
但是,如果我将表从 InnoDB 更改为 MyISAM,一切正常。 The InnoDB insert works if I run it through PHPMyAdmin.
如果我通过 PHPMyAdmin 运行 InnoDB 插入,它就可以工作。
I've boiled my problem down to this piece of code (my db credentials are correct as the MyISAM works fine):我把我的问题归结为这段代码(我的数据库凭据是正确的,因为 MyISAM 工作正常):
$insert_sql = "insert into products_vendors (";
$insert_sql.= "`vendor_id`,";
$insert_sql.= "`product_id`,";
$insert_sql.= "`original_quantity`,";
$insert_sql.= "`quantity`,";
$insert_sql.= "`price`,";
$insert_sql.= "`created`,";
$insert_sql.= "`valid_until` ";
$insert_sql.= ") values (";
$insert_sql.= "'1', '2', '3', '4', '5', '6', '7');";
$db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD, array(PDO::ATTR_PERSISTENT, true));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$st = $db->prepare($insert_sql);
$st->execute();
What would account for this code working fine with MyISAM but failing silently for InnoDB?什么会解释这段代码在 MyISAM 上运行良好,但在 InnoDB 上却静默失败?
Many thanks for any guidance.非常感谢您的任何指导。
2 ideas: 2个想法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.