Yii Framework: table for active record class cannot be found in database

I hope hivemind has some more suggestions for fixing this error from the Yii Framework. The exact error specific to our setup is:

CDbException The "users" table for the active "Users" record class cannot be found in the database.

I am using the Yii Framework 1.1.11-dev from SVN, although this was just an attempt to fix the problem. We used the latest stable version 1.1.10.

We are trying to install code on our live server that works in my dev env. I feel the problem is almost certainly related to the database configuration, but I'm not sure where to find it.

I already searched here and searched the Yii forums where I found this problem listed a couple of times. Recommended fixes we have already tried include

  • removal of a host and port from dsn
  • with and without a schema for the table name (for example, "users" and "public.users")
  • GRANT ALL ON THE DATABASE [dbname] Go to postgres
  • Provide everything on each table in db using the code found here

The environment is as follows:

  • DEV - OSX 10.7, PHP 5.3.10, PostgreSQL 9.0.3
  • PROD - FC15, PHP 5.3.10, PostgreSQL 9.0.7

The error indicates that the user table does not exist, although this is pretty clear.

~$ psql -U postgres psql (9.0.7) Type "help" for help. postgres=# \dt List of relations Schema | Name | Type | Owner --------+------------------------------+-------+---------- { ... removed for brevity ... } public | users | table | postgres 

Our configuration in protected / config / main.php

 'db'=>array( 'connectionString' => 'pgsql:dbname=lppsync', 'emulatePrepare' => true, 'username' => 'postgres', 'password' => '', ), 

And the corresponding part of the user model

 class Users extends CActiveRecord { /** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Users the static model class */ public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'users'; } 
+4
source share
3 answers

It turns out that the data was not imported into the named database. Instead, it was imported into a user database. In this case, "postgres". The fix in this case is to re-import the data to the correct location or change the Yii configuration (our solution). New connection settings:

 'db'=>array('connectionString' => 'pgsql:dbname=postgres', 'emulatePrepare' => true, 'username' => 'postgres','password' => '',) 
+1
source

Yii db metadata caches , maybe this is a problem? Try to clear the metadata cache or disable the cache altogether.

Typically, the / wwwroot/assets folder contains these cache files.

Also check that there is no free space on your device (disk).

Source: suggestion of one of the comments on this question - Yii Framework: the table for the active record class cannot be found in the database

+1
source

I came across a similar error with MySQL. In my case, the problem was that I made a mistake in granting rights to the user. Starting the MySQL client, I got the correct "message about the abandonment of the command", but from the point of view of Yii it looked like the tables did not exist at all.

The solution was to properly grant the rights:

grant all on yiiapp.* to 'yii'@'localhost' identified by 'yii';

0
source

Source: https://habr.com/ru/post/1414404/


All Articles