PDO Multi-query “SQLSTATE[HY000]: General error”

前端 未结 2 895
野趣味
野趣味 2021-01-07 09:23

I\'m still learning PDO so I might of missed something but basically I\'m trying to insert a row into a table and then select the generated id.

I\'m not sure if it l

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 09:39

    I'm pretty sure the mysql driver for PDO (maybe mysql itself?) does not support multi-query prepared statements.

    Instead of SELECT LAST_INSERT_ID() in your query, use Conexion::$cn->lastInsertId() after your $query->execute()

提交回复
热议问题