Php Yii-设置活动记录动态表名称时出错

Php Yii-设置活动记录动态表名称时出错,php,mysql,activerecord,yii,Php,Mysql,Activerecord,Yii,嗨,我正在尝试使用一个模型,该模型将从另一个数据库生成动态表名。我已通过重写tableName()函数来设置表名。但我有一个错误,说 The table "powerDovakin_{FUS.THUM}" for active record class "PowersTransactions" cannot be found in the database 这是正在讨论的模型类 <?php class PowersTransactions extends CActiv

嗨,我正在尝试使用一个模型,该模型将从另一个数据库生成动态表名。我已通过重写tableName()函数来设置表名。但我有一个错误,说

The table "powerDovakin_{FUS.THUM}" for active record class "PowersTransactions" cannot be found in the database
这是正在讨论的模型类

<?php


class PowersTransactions
        extends CActiveRecord {


    public $symbol ;


    public function __construct ($symbol) {
        $this->symbol = $symbol;
    }



    /**
     * @return string the associated database table name
     */
    public function tableName () {
        return "powerDovakin_{" . $this->symbol ."}";
    }    

    /**
     * @return array relational rules.
     */
    public function relations () {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array (
                ) ;
    }


    /**
     * Returns the static model of the specified AR class.
     * Please note that you should have this exact method in all your CActiveRecord descendants!
     * @param string $className active record class name.
     * @return InsidersTransactions the static model class
     */
    public static function model ( $className = __CLASS__ ) {
        return parent::model ( $className ) ;
    }






    /**
     * Overriding parent getDbConnection to allow for use of different database
     */
    public function getDbConnection () {

        return Yii::app ()->powersDovakin ;
    }



}
从上面的跟踪中,我可以发现Yii在点的周围加上了反勾(`),并可能将点后的部分解释为列名

我的问题是如何让我使用这种表名。我希望我能改变桌子的名字,但我现在忙得不可开交。我不能改变它们,因为它们不是我的。所以表名也是这样的

powerDovakin_{FUS.THUM} , powerDovakin_{ROH.THUM}, etc 
是否可以让模型接受这样的名称。请提供任何帮助,因为我找不到任何解决这个问题的方法。如果我能在这方面得到任何帮助,我将不胜感激

谢谢,提前,
Maxx

上述代码可能使您能够从表中获取记录,但我认为您不能插入任何行

您需要调用父类的构造函数才能获得所需的功能

    class PowersTransactions extends CActiveRecord {


        public $symbol;


        public function __construct ($symbol) {
            $this->symbol = $symbol;
            parent::__construct();
        }

        /**
         * other code goes here
         */

}

上面的代码已经过测试,正在运行

有人知道如何执行此操作吗?是的,这也适用于插入数据。非常感谢您提供此片段。:-)
    class PowersTransactions extends CActiveRecord {


        public $symbol;


        public function __construct ($symbol) {
            $this->symbol = $symbol;
            parent::__construct();
        }

        /**
         * other code goes here
         */

}