且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么PDO :: lastInsertId返回0?

更新时间:2023-02-19 22:40:46

从查询中删除分号或分号后的空格,或两者都删除:

Remove the semicolon or the whitespace after the semicolon or both from your query:

$sql = "
INSERT INTO `wallet` (`uid`, `created_at`, `amount`, `type`, `payment_id`) VALUES (:uid, CURRENT_TIMESTAMP, :amount, 'payment', :payment_id)
";