M
M
MiroMichail2015-07-28 12:29:11
MySQL
MiroMichail, 2015-07-28 12:29:11

Why in Yii the model does not see the table in the database?

After the transfer to the server, the following situation periodically occurs:
The table "{{user}}" for active record class "User" cannot be found in the database.
Moreover, this occurs only sometimes, sometimes more often, sometimes less often and only on the server, there are no problems in the local version. There is a table in the database, there is no error in the title.
The project uses the Smarty template engine.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Osher, 2015-07-28
@miraage

As far as I remember, bracket-syntax for table names is only enabled when tablePrefix is ​​present.
If you don't have a database table prefix, remove the brackets.

V
Vit, 2015-07-28
@fornit1917

A similar error fell when there were problems connecting to the database.

M
Mirocow, 2015-07-28
@mirocow

set schema caching when connecting to the
database like this
```php
'components' => [
// ...
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql :host=localhost;dbname=my_table',
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
// turn on schema caching to improve performance
'schemaCache' => 'db_cache', // Which engine will cache
'schemaCacheDuration' => 3600, // Cache time
'enableSchemaCache' => true, // Enable db table schema caching
],
// ...
],
```

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question