A
A
Alexander2016-11-10 11:53:17
Yii
Alexander, 2016-11-10 11:53:17

In Yii 1, active record does not find the table in the database, but it is there! Will I mark?

I get this error:
CDbException
The table "products_to_categories" mentioned in the active record of class "ProductsToCategories" was not found in the database.
1. There is a table "products_to_categories" in the database!
2. In the "ProductsToCategories" class, the table name is spelled CORRECTLY!
public function tableName() {
return 'products_to_categories';
}
WHY!?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2016-11-11
@kascor

The problem was this:
Before the line that threw the error, there was a lot of code, and when it came to it, mysql went into trance with the error SQLSTATE[HY000]: General error: 2006 Mysql server has gone away, and PDO did not issue anything, and swore that there were no signs, but in fact there was no connection to the database !!!
The solution was to increase wait_timeout from 10 to 60, in /etc/mysql/my.cnf

M
mitaichik, 2016-11-10
@mitaichik

1. See if the model has rewritten the method that receives the connection instance to the database (something like getDb, I don’t remember already)
2. Yii can cache the schema (depends on your configs) - if the tables are new and the cache is enabled, you need to clear the cache.

M
Maxim Timofeev, 2016-11-10
@webinar

Perhaps everything is trite, a Cyrillic letter in the title? Go to the database, copy the name and paste it into the model.

E
eudj1n, 2016-11-10
@eudj1n

If the problem is not in the model, try to get the data via DAO - www.yiiframework.com/doc/guide/1.1/en/database.dao

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question