D
D
Dmitry Bay2015-04-17 07:40:41
PostgreSQL
Dmitry Bay, 2015-04-17 07:40:41

SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax?

There is a standard CRUD from GII per model.
Framework Yii2.
Postgresql database.
I work with basis through Active Record.
When editing the model - everything is ok.
But when creating a new one while saving: I get an error

SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax

Which links to /vendor/yiisoft/yii2/db/Schema.php:
return $this->db->pdo->lastInsertId($sequenceName === '' ? null : $sequenceName);

How would I see the problem is that we can't get the lastinsertid from the database, but didn't expect the problem to be in Yii2 out of the box.
Question - where to dig? how to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korovin, 2015-04-17
@kawabanga

Yes, it seems like there is no such problem - there are 2 databases in the project: mysql + postgresql.
Looked into Schema.php:

public function getLastInsertID($sequenceName = '')
    {
        if ($this->db->isActive) {
            return $this->db->pdo->lastInsertId($sequenceName === '' ? null : $this->quoteSimpleTableName($sequenceName));
        } else {
            throw new InvalidCallException('DB Connection is not active.');
        }
    }

the syntax is different (wrapped in single quotes if necessary). Perhaps you and I have different versions of Yii2. And the error "invalid name syntax" suggests the same idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question