douhang1913 2012-09-17 16:11
浏览 77
已采纳

php yii在数据库中找不到活动记录类“”的表“”

I have created all my models for my mysql db in yii which works fine. Now I want to add an extra db which is mssql 2000. I have set up php and the pdo adapter after several hours. Now I am trying to create a model for just a single table in mssql. it does not let me. I get the following error.

The table "[xxx Geo Limited\$Fixed Asset]" for active record class "FixedAsset" cannot be found in the database.



    private $_model;
2301 
2302     /**
2303      * Constructor.
2304      * @param CActiveRecord $model the model instance
2305      */
2306     public function __construct($model)
2307     {
2308         $this->_model=$model;
2309 
2310         $tableName=$model->tableName();
2311         if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
2312             throw new CDbException(Yii::t('yii','The table "{table}" for active record class "{class}" cannot be found in the database.',
2313                 array('{class}'=>get_class($model),'{table}'=>$tableName)));
2314         if($table->primaryKey===null)
2315         {
2316             $table->primaryKey=$model->primaryKey();
2317             if(is_string($table->primaryKey) && isset($table->columns[$table->primaryKey]))
2318                 $table->columns[$table->primaryKey]->isPrimaryKey=true;
2319             else if(is_array($table->primaryKey))
2320             {
2321                 foreach($table->primaryKey as $name)
2322                 {
2323                     if(isset($table->columns[$name]))
2324                         $table->columns[$name]->isPrimaryKey=true;

My model is called FixedAsset and my table in mssql is called [xxx Geo Limited\$Fixed Asset]

  • 写回答

1条回答 默认 最新

  • doujiang2812 2012-09-17 16:16
    关注

    solved the problem, use double quotes when specifying the table

    public function tableName()
        {
            //exit("help");
            return "[xxxGeo Limited\$Fixed Asset]";
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度