Answer the question
In order to leave comments, you need to log in
PDO exception number 42601, how to fix?
Good evening. There is an expression:
$this->insertStmt = $this->connection->getPdo()->prepare("
INSERT INTO files (
real_name,
virtual_name,
album,
size,
resolution,
duration,
comment,
path,
user
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
");
protected function doInsert(object $object)
{
$values = [
$object->getRealName(),
$object->getVirtualName(),
$object->getAlbum(),
$object->getSize(),
$object->getResolution(),
$object->getDuration(),
$object->getComment(),
$object->getPath(),
$object->getUser(),
];
$this->insertStmt->execute($values);
}
array(9) {
[0]=> string(15) "BvrK9z6UPxY.jpg"
[1]=> string(16) "1265dde1c67abc1c"
[2]=> string(23) "По умолчанию"
[3]=> int(54973)
[4]=> string(7) "720x430"
[5]=> NULL
[6]=> string(0) ""
[7]=> string(108) "files/id5cd487313a93a/По умолчанию/2019-05-10/1265dde1c67abc1c.jpg"
[8]=> string(15) "id5cd487313a93a"
}
Type: PDOException
Code: 42601
Message: SQLSTATE[42601]: Syntax error: 7 ОШИБКА: ошибка синтаксиса (примерное положение: "user") LINE 11: user ^
Answer the question
In order to leave comments, you need to log in
The DBMS unequivocally answers that it does not agree with the syntax.
If you do not read the lists of reserved words - then yes, it may not be entirely obvious why this query is syntactically incorrect. But nevertheless, the word user is still reserved by both the SQL standards and the specific implementation in postgresql. Therefore, it cannot be used as an unquoted identifier .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question