我希望 hivemind 对处理来自 Yii 框架的这个错误有更多的建议。特定于我们的设置的确切错误是:
CDbException在数据库中找不到活动记录类“用户”的表“用户”。
我正在使用来自 SVN 的 Yii Framework 1.1.11-dev,尽管这只是解决问题的尝试。我们正在运行最新的稳定版本 1.1.10。
我们正在尝试使用在我的开发环境中运行的代码部署到我们的实时服务器。我觉得问题几乎可以肯定是数据库配置差异,但我不确定在哪里可以找到它。
我已经在这里搜索并搜索了 Yii 论坛,在其中我发现这个问题列出了几次。我们已经尝试过的建议修复包括
- 从 dsn 中删除主机和端口
- 表名有无模式(即“users”和“public.users”)
- 将数据库 [dbname] 上的所有内容授予 postgres
- 使用此处找到的代码授予数据库中每个表的所有权限
环境如下:
- 开发 - OSX 10.7、PHP 5.3.10、PostgreSQL 9.0.3
- 产品 - FC15、PHP 5.3.10、PostgreSQL 9.0.7
该错误表明“用户”表不存在,尽管它很明显存在。
~$ 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
我们在 protected/config/main.php 中的配置
'db'=>array(
'connectionString' => 'pgsql:dbname=lppsync',
'emulatePrepare' => true,
'username' => 'postgres',
'password' => '',
),
用户模型的相关部分是
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';
}