Yii не видит таблицу
Делаю поиск по бд выдает ошибку, а таблица сама есть
CDbException
The table "users" for active record class "Users" cannot be found in the database.
/var/www/site/yii/framework/db/ar/CActiveRecord.php(2310)
Ругается именно на
public function __construct($model) { $this->_model=$model;
$tableName=$model->tableName();
if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
throw new CDbException(Yii::t('yii','The table "{table}" for active record class "{class}" cannot be found in the database.',
array('{class}'=>get_class($model),'{table}'=>$tableName)));
if($table->primaryKey===null)
{
$table->primaryKey=$model->primaryKey();
if(is_string($table->primaryKey) && isset($table->columns[$table->primaryKey]))
$table->columns[$table->primaryKey]->isPrimaryKey=true;
elseif(is_array($table->primaryKey))
{
foreach($table->primaryKey as $name)
{
if(isset($table->columns[$name]))
$table->columns[$name]->isPrimaryKey=true;
}
}
}
$this->tableSchema=$table;
$this->columns=$table->columns;
foreach($table->columns as $name=>$column)
{
if(!$column->isPrimaryKey && $column->defaultValue!==null)
$this->attributeDefaults[$name]=$column->defaultValue;
}
foreach($model->relations() as $name=>$config)
{
$this->addRelation($name,$config);
}
}
main.php
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=db',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
помогите решить проблему
Ответы (1 шт):
Автор решения: Haku Kimura
→ Ссылка
Первое, что бросается в глаза, у вас в конфигурационном файле указан префикс для всех таблиц в БД:
'db' => array(
'tablePrefix' => 'tbl_',
),
убедитесь, что он присутствует в названии соответствующей таблицы или удалите это свойство, если не используете префиксы.