PDO lastInsertId() always return 0

前端 未结 5 494
花落未央
花落未央 2020-11-29 12:14

I\'ve come across with a problem. My framework was working just fine with PHP 5.3.0. I upgraded my PHP version to PHP 5.4.x and I started to have few issues with some parts

5条回答
  •  迷失自我
    2020-11-29 12:28

    The one other problem could be using $pdo->exec($sql) instead of $pdo->query($sql).

    exec($sql) will return always 0 when you use $pdo->lastInsertId(). So use query() instead.

提交回复
热议问题