我在yii中创建了我的mysql数据库的所有模型,效果很好。现在我想添加一个额外的数据库,这是mssql 2000.几个小时后我已经设置了php和pdo适配器。现在我试图在mssql中为一个表创建一个模型。它不让我。我收到以下错误。
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;
我的模型名为FixedAsset
,我的mssql表名为[xxx Geo Limited\$Fixed Asset]
答案 0 :(得分:2)
解决了问题,在指定表时使用双引号
public function tableName()
{
//exit("help");
return "[xxxGeo Limited\$Fixed Asset]";
}