我正在触发一个适用于一个页面的更新查询,但不适用于另一个页面。
这是输出:
致命错误:带有消息的未捕获异常“Doctrine_Connection_Mysql_Exception” 'SQLSTATE[HY093]: 无效的参数号:绑定变量的数量与标记的数量不匹配' in C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php:1084 堆栈跟踪: #0 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection\Statement.php(253): Doctrine_Connection->rethrowException(Object(PDOException), 对象(Doctrine_Connection_Statement)) #1 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php(1049): Doctrine_Connection_Statement->执行(数组) #2 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Query\Abstract.php(1091): Doctrine_Connection->exec('UPDATE users SE...', Array) #3 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Query\Abstract.php(1142): Doctrine_Query_Abstract->_execute(Array) #4 C:\xampp\htdocs\fanyer\doctrine\models\Users.php(122): Doctrine_Query_Abstract->execute() #5 C:\xampp\htdocs\fanyer\include\update_profile.inc.php(18): 用户->update_coach_details('', '', NULL, 'Select', 'dav', 'coach', '3') #6 在 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php 第 1084 行
这是我的代码:
public function update_coach_details($fname,$lname,$city,$state,$school,$rights,$user_id)
{
return Doctrine_Query::create()
->update('Users')
->set('f_name', '?', $fname)
->set('l_name', '?', $lname)
->set('city', '?', $city)
->set('state', '?', $state)
->set('school', '?', $school)
->set('rights', '?', $rights)
->where("id = '$user_id'")
->execute();
}
$account_type=$_SESSION['rights'];
$fname= $_POST['fname'];
$lname= $_POST['lname'];
$state= $_POST['state'];
$school= $_POST['school'];
$sports= $_POST['sports'];
$sports_array = explode(',',$sports);
$user_id=$_SESSION['user_id'];
$users= new Users();
$users->update_coach_details($fname,$lname,$city,$state,$school,$account_type,$user_id);
问题是我传递的参数引起的吗?