InnoDB插入会以静默方式失败,当表是MyISAM时可以正常工作

|| 我在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;
我正在使用PHP和PDO进行插入。执行代码后,插入将以静默方式失败。但是,如果我将表从InnoDB更改为MyISAM,则一切正常。如果我通过PHPMyAdmin运行InnoDB插入,则可以正常工作。 我将问题归结为以下代码(由于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();
什么可以解释此代码与MyISAM正常工作,但对InnoDB静默失败? 非常感谢您的指导。     
已邀请:
2个想法: 您忘记了提交交易。 您的持久连接处于不确定状态     

要回复问题请先登录注册