0
PDO 확장에 익숙하지 않아 코드에서 무엇이 잘못되었는지를 알 수 없습니다. 코드 스 니펫 : PDO 예외 "SQLSTATE [HY093] : 잘못된 매개 변수 번호 : 바인딩 된 변수의 수가 토큰 수와 일치하지 않습니다."
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
이전의 모든 쿼리
는 PDO 예외를 생성하지 않습니다,하지만 마지막 INSERT 쿼리 :이 코드가 실행 try {
$this->PDO->exec('SET AUTOCOMMIT = 0');
$this->PDO->exec('START TRANSACTION');
$this->PDO->prepare("UPDATE office_users
SET balance = balance - ?
WHERE id = ?")
->execute(array($sbs_price, $this->user->id)
);
$user_balance -= $sbs_price;
$this->PDO->prepare("UPDATE office_company
SET pay_days = pay_days + ?
WHERE inn = ?
AND user_id = ?")
->execute(array(
$sbs_period_days,
$company_inn,
$this->user->id)
);
$fin_string = $company_name.' ИНН '.$company_inn.' продление '.$sbs_period_month. ' мес.';
$this->PDO->prepare("INSERT INTO office_fin_transactions
(user_id, date_register, dsc, amount, status)
VALUES (?, ?, ?, ?, ?)")
->execute(array(
$this->user->id.
date("Y-m-d H:i:s"),
$fin_string,
$sbs_price,
0)
);
$this->PDO->exec("COMMIT");
} catch (PDOException $Exception) {
$this->PDO->exec("ROLLBACK");
echo json_encode(array('result' => false,
'error' => $Exception->getMessage()));
exit;
}
echo json_encode(array('result'=>'success',
'inn' => $company_inn,
'sbs_period' => $sbs_period_month,
'company_name' => $company_name,
'balance' => $user_balance)
);
exit;
하기 전에 스크립트의 시작, PDO는이 방식으로 구성되어있다 않습니다. 변수의
값 : 테이블 office_fin_transactions의
$this->user->id == 158;
$fin_string == "ООО "Тестовые системы" - 2954 ИНН 123456 продление 6 мес."
$sbs_price == 1000;
Stucture은 다음과 같습니다
문제점은 무엇입니까? 아이디어가 있으면 도와주세요.
아, 정확하게. 고마워요! – d7r