gpt4 book ai didi

php yii 在数据库中找不到事件记录类 ""的表 ""

转载 作者:行者123 更新时间:2023-11-29 02:31:34 24 4
gpt4 key购买 nike

我已经在 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]

最佳答案

解决问题,指定表格时使用双引号

public function tableName()
{
//exit("help");
return "[xxxGeo Limited\$Fixed Asset]";
}

关于php yii 在数据库中找不到事件记录类 ""的表 "",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12463186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com