Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number'

后端 未结 1 1718
我寻月下人不归
我寻月下人不归 2021-01-26 04:41

I\'m receiving an error whenever I attempt to insert into my database using PDO.

public function save($primaryKey = \"\") {
        $validate = $this->rules()         


        
1条回答
  •  别那么骄傲
    2021-01-26 04:46

    I think this might be because you have decared each binding twice in the statement e.g. :firstname appears in the VALUES clause as well as the ON DUPLICATE KEY UPDATE clause.

    You only pass 8 bindings to the $stmt->execute but PDO is looking for 16.

    You could try naming them slightly different in the ON DUPLICATE KEY UPDATE clause giving you a query such as e.g.

    INSERT INTO am_administrator (firstName,lastName,username,password,email,isSuperUser,dateCreated,dateLastModified) VALUES (:firstName,:lastName,:username,:password,:email,:isSuperUser,:dateCreated,:dateLastModified) ON DUPLICATE KEY UPDATE firstName = :update_firstName,lastName = :update_lastName,username = :update_username,password = :update_password,email = :update_email,isSuperUser = :update_isSuperUser,dateCreated = :update_dateCreated,dateLastModified = :update_dateLastModified;

    0 讨论(0)
提交回复
热议问题