Php 调用未定义的方法Cake\Database\Log\LoggingStatement::bindParam()
我在解决这个问题上遇到了麻烦,我 调用未定义的方法 Cake\Database\Log\LoggingStatement::bindParam() 使用过程调用将数据保存到数据库中时出错 这是我的post方法代码Php 调用未定义的方法Cake\Database\Log\LoggingStatement::bindParam(),php,cakephp,stored-procedures,Php,Cakephp,Stored Procedures,我在解决这个问题上遇到了麻烦,我 调用未定义的方法 Cake\Database\Log\LoggingStatement::bindParam() 使用过程调用将数据保存到数据库中时出错 这是我的post方法代码 if ($this->request->is('post')) { $pi_classroom_name = $this->request->getData('classroom_name'); $pi_grade = $this->request->
if ($this->request->is('post')) {
$pi_classroom_name = $this->request->getData('classroom_name');
$pi_grade = $this->request->getData('grade');
$pi_subject = $this->request->getData('subject');
$pi_user_id = 1;
$sql = 'CALL jh_add_update_classroom(:pi_classroom_id,:pi_classroom_name,:pi_grade,:pi_subject,:pi_user_id,@po_classroom_id,@po_status,@po_status_message)';
$stmt = $this->connection->prepare($sql);
$stmt->bindParam(':pi_classroom_id', null, PDO::PARAM_STR);
$stmt->bindParam(':pi_classroom_name', $pi_classroon_name, PDO::PARAM_STR);
$stmt->bindParam(':pi_grade', $pi_grade, PDO::PARAM_STR);
$stmt->bindParam(':pi_subject', $pi_subject, PDO::PARAM_STR);
$stmt->bindParam(':pi_user_id', $pi_user_id, PDO::PARAM_STR);
$stmt->execute();
$stmt->closeCursor();
}
正如错误消息所述,没有这样的方法。您不是在本机
\PDOStatement
对象上操作,而是在\Cake\Database\Log\LoggingStatement
对象(它扩展了\Cake\Database\statement接口
实现)上操作,用于绑定的正确方法是bind()
或bindValue()
另见
$stmt->bindValue('pi_classroom_id', null, 'string');
$stmt->bindValue('pi_classroom_name', $pi_classroom_name, 'string');
// ...