postgresql – Yii Framework:在数据库中找不到活动记录类的表
我希望hivemind有一些关于从Yii Framework处理这个错误的建议.我们设置的具体错误是:
我正在使用来自SVN的Yii Framework 1.1.11-dev,尽管这只是尝试解决问题.我们运行的是最新的稳定版本1.1.10. 我们正尝试使用在我的开发环境中运行的代码部署到我们的实时服务器.我觉得问题几乎肯定是数据库配置的差异,但我不知道在哪里可以找到它. 我已经在这里搜索并搜索了Yii论坛,在那里我发现了这个问题几次.我们已经尝试过的建议修复包括 >从dsn中删除主机和端口 环境如下: > DEV – OSX 10.7,PHP 5.3.10,PostgreSQL 9.0.3 该错误表明表“用户”不存在,尽管很明显. ~$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' => '',), 而Users模型的相关部分是 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'; } 解决方法
事实证明,数据未导入指定的数据库.相反,它被导入到用户的数据库中.在这种情况下’postgres’.在这种情况下,修复是将数据重新导入到正确的位置,或更改Yii配置(我们的决定).新的连接设置:
'db'=>array('connectionString' => 'pgsql:dbname=postgres',) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |