Yii Framework:在数据库中找不到活动记录类的表 [英] Yii Framework: The table for active record class cannot be found in the database

查看:251
本文介绍了Yii Framework:在数据库中找不到活动记录类的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望蜂巢有关Yii Framework的错误有更多建议。特定于我们的设置的确切错误是:

I'm hoping the hivemind has some more suggestions on dealing with this error from Yii Framework. The exact error, specific to our setup is:


CDbException 表中的活动记录类 users用户
在数据库中找不到。

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

我正在使用SVN的Yii Framework 1.1.11-dev,尽管这只是解决问题的一种尝试。我们正在运行最新的稳定版本1.1.10。

I'm using Yii Framework 1.1.11-dev from SVN, though this was just an attempt to fix the problem. We were running the latest stable version 1.1.10.

我们正尝试使用在我的开发环境中运行的代码将其部署到实时服务器中。我觉得问题几乎可以肯定是数据库配置上的差异,但是我不确定在哪里可以找到它。

We are trying to deploy to our live server with code that is working in my dev env. I feel like the problem is almost certainly a database configuration difference, but I'm not sure where to find it.

我已经在这里搜索并搜索了Yii论坛,我发现此问题列出了几次。我们已经尝试过的建议修复方法包括

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


  • 从dsn中删除主机和端口

  • 并且没有表名的模式(即 users和 public.users)

  • 将所有数据库上的数据库[dbname]授予postgres

  • Grant 在此找到的代码

  • removing the host and port from the dsn
  • with and without schema for the tablename (ie "users" and "public.users")
  • GRANT ALL ON DATABASE [dbname] TO postgres
  • Grant all on each table in the db using code found here

环境如下:


  • DEV-OSX 10.7,PHP 5.3.10,PostgreSQL 9.0.3

  • PROD-FC15,PHP 5.3.10,PostgreSQL 9.0.7

该错误表明表 users不存在,尽管很明显。

The error indicates the table "users" does not exist, though it quite clearly does.

~$ 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中的配置

Our configuration in protected/config/main.php

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

而用户模型的相关部分是

And the relevant part of the Users model is

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配置(我们的决定)。新的连接设置:

It turns out the data was not imported to the named database. Instead it was imported to the user's database. In this case 'postgres'. The fix in this case is to re-import the data to the correct location, or change the Yii config (our decision). New connection settings:

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

这篇关于Yii Framework:在数据库中找不到活动记录类的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆