我收到此错误消息:
活动记录类的表“Permissionactions” 在数据库中找不到“Permissionactions”。
/var/www/html/YII/framework/db/ar/CActiveRecord.php(2310)
private $_model;
/**
* Constructor.
* @param CActiveRecord $model the model instance
*/
public function __construct($model)
{
$this->_model=$model;
$tableName=$model->tableName();
if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
throw new CDbException(Yii::t('yii','The table "{table}" for active record class "{class}" cannot be found in the database.',
array('{class}'=>get_class($model),'{table}'=>$tableName)));
if($table->primaryKey===null)
{
$table->primaryKey=$model->primaryKey();
if(is_string($table->primaryKey) && isset($table->columns[$table->primaryKey]))
$table->columns[$table->primaryKey]->isPrimaryKey=true;
elseif(is_array($table->primaryKey))
{
foreach($table->primaryKey as $name)
{
if(isset($table->columns[$name]))
$table->columns[$name]->isPrimaryKey=true;
我的数据库中没有任何名为table的Permissionactions。这是main.php连接:
'db' => array(
'connectionString' => 'mysql:host=xxxxxxxxx;dbname=xxxxx',
'emulatePrepare' => true,
'username' => 'xxxxxxxx',
'password' => 'xxxxxxxxxxx',
'charset' => 'utf8',
),
'dbpermissions' => array(
'connectionString' => "mysql:host=xxxxxxxx;dbname=xxxxx",
'emulatePrepare' => true,
'username' => 'xxxxxxxx',
'password' => 'xxxxxxxxxxxxxxx',
'charset' => 'utf8',
'class' => 'CDbConnection'
),
我知道为什么会得到这个?
更新: 这是控制器:
class MainController extends Controller {
public $model;
public function init(){
$this->model = Permissionactions::model();
}
...
和Permissionsactions类(模型):
class Permissionactions extends ActiveRecord{
private $connection_permission;
//private $connection_invetory;
/**
* @see db connections from config/main.php
*/
public function __construct(){
$this->connection_permission = Yii::app()->dbpermissions;
}
public static function model($className=__CLASS__){
return parent::model($className);
}
....
在我的本地主机上它可以工作。但现在我把它放在服务器上,它向我显示了这个错误。
答案 0 :(得分:0)
使用您的编辑器/ IDE功能搜索您的代码在文件中搜索/在项目中搜索并找到字符串
Permissionactions
提供有关您的问题和配置的更多信息。