sarvan75 / yii-user-management

Automatically exported from code.google.com/p/yii-user-management
0 stars 0 forks source link

The table "User" for active record class "User" cannot be found in the database. #186

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. latest yii
2. trying RBAC
3. login admin/admin, getting error

Trying use reciepts of same issues, but this didn't work...
prefix, lower-upper case...

CDbException
The table "User" for active record class "User" cannot be found in the 
database. 

X:\home\fblood\www\framework\db\ar\CActiveRecord.php(2264)

2252     private $_model;
2253 
2254     /**
2255      * Constructor.
2256      * @param CActiveRecord $model the model instance
2257      */
2258     public function __construct($model)
2259     {
2260         $this->_model=$model;
2261 
2262         $tableName=$model->tableName();
2263         
if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
2264             throw new CDbException(Yii::t('yii','The table "{table}" for 
active record class "{class}" cannot be found in the database.',
2265                 
array('{class}'=>get_class($model),'{table}'=>$tableName)));
2266         if($table->primaryKey===null)
2267         {
2268             $table->primaryKey=$model->primaryKey();
2269             if(is_string($table->primaryKey) && 
isset($table->columns[$table->primaryKey]))
2270                 $table->columns[$table->primaryKey]->isPrimaryKey=true;
2271             else if(is_array($table->primaryKey))
2272             {
2273                 foreach($table->primaryKey as $name)
2274                 {
2275                     if(isset($table->columns[$name]))
2276                         $table->columns[$name]->isPrimaryKey=true;
Stack Trace
#0  +– X:\home\fblood\www\framework\db\ar\CActiveRecord.php(379): 
CActiveRecordMetaData->__construct(User) 
374         if(isset(self::$_models[$className]))
375             return self::$_models[$className];
376         else
377         {
378             $model=self::$_models[$className]=new $className(null);
379             $model->_md=new CActiveRecordMetaData($model);
380             $model->attachBehaviors($model->behaviors());
381             return $model;
382         }
383     }
384 

#1  +– X:\home\fblood\www\protected\models\User.php(17): 
CActiveRecord::model("User") 
12     const ROLE_MODER = 'moderator';
13     const ROLE_USER = 'user';
14     const ROLE_BANNED = 'banned';
15  
16     public static function model($className=__CLASS__){
17         return parent::model($className);
18     }
19  
20     public function tableName(){
21         return 'User';
22     }

#2  +– X:\home\fblood\www\protected\components\UserIdentity.php(25): 
User::model() 
20     protected $_id;
21  
22     // Данный метод 
вызывается один раз 
при аутентификации 
пользователя.
23     public function authenticate(){
24         // РџСЂРѕРёР·РІРѕРґРёРј 
стандартную 
аутентификацию, 
описанную в 
руководстве.
25         $user = User::model()->find('LOWER(login)=?', 
array(strtolower($this->username)));
26         if(($user===null) or (md5($this->password)!==$user->password)) {
27             $this->errorCode = self::ERROR_USERNAME_INVALID;
28         } else {
29             // В качестве 
идентификатора 
будем использовать id, а 
РЅРµ username,
30             // как это 
определено по 
умолчанию. 
Обязательно нужно 
переопределить

#3  +– X:\home\fblood\www\protected\models\LoginForm.php(52): 
UserIdentity->authenticate() 
47     public function authenticate($attribute,$params)
48     {
49         if(!$this->hasErrors())
50         {
51             $this->_identity=new 
UserIdentity($this->username,$this->password);
52             if(!$this->_identity->authenticate())
53                 $this->addError('password','Incorrect username or 
password.');
54         }
55     }
56 
57     /**

#4  +– X:\home\fblood\www\framework\validators\CInlineValidator.php(43): 
LoginForm->authenticate("password", array()) 
38      * @param string $attribute the attribute being validated
39      */
40     protected function validateAttribute($object,$attribute)
41     {
42         $method=$this->method;
43         $object->$method($attribute,$this->params);
44     }
45 
46     /**
47      * Returns the JavaScript code needed to perform client-side validation 
by calling the {@link clientValidate} method.
48      * In the client validation code, these variables are predefined:

#5  +– X:\home\fblood\www\framework\validators\CValidator.php(197): 
CInlineValidator->validateAttribute(LoginForm, "password") 
192         else
193             $attributes=$this->attributes;
194         foreach($attributes as $attribute)
195         {
196             if(!$this->skipOnError || !$object->hasErrors($attribute))
197                 $this->validateAttribute($object,$attribute);
198         }
199     }
200 
201     /**
202      * Returns the JavaScript needed for performing client-side validation.

#6  +– X:\home\fblood\www\framework\base\CModel.php(158): 
CValidator->validate(LoginForm, null) 
153         if($clearErrors)
154             $this->clearErrors();
155         if($this->beforeValidate())
156         {
157             foreach($this->getValidators() as $validator)
158                 $validator->validate($this,$attributes);
159             $this->afterValidate();
160             return !$this->hasErrors();
161         }
162         else
163             return false;

#7  +– X:\home\fblood\www\protected\controllers\SiteController.php(88): 
CModel->validate() 
83         // collect user input data
84         if(isset($_POST['LoginForm']))
85         {
86             $model->attributes=$_POST['LoginForm'];
87             // validate user input and redirect to the previous page if valid
88             if($model->validate() && $model->login())
89                 $this->redirect(Yii::app()->user->returnUrl);
90         }
91         // display the login form
92         $this->render('login',array('model'=>$model));
93     }

#8  +– X:\home\fblood\www\framework\web\actions\CInlineAction.php(50): 
SiteController->actionLogin() 
45         $controller=$this->getController();
46         $method=new ReflectionMethod($controller, $methodName);
47         if($method->getNumberOfParameters()>0)
48             return $this->runWithParamsInternal($controller, $method, 
$params);
49         else
50             return $controller->$methodName();
51     }
52 
53 }

#9  +– X:\home\fblood\www\framework\web\CController.php(309): 
CInlineAction->runWithParams(array("r" => "site/login")) 
304     {
305         $priorAction=$this->_action;
306         $this->_action=$action;
307         if($this->beforeAction($action))
308         {
309             if($action->runWithParams($this->getActionParams())===false)
310                 $this->invalidActionParams($action);
311             else
312                 $this->afterAction($action);
313         }
314         $this->_action=$priorAction;

#10  +– X:\home\fblood\www\framework\web\CController.php(287): 
CController->runAction(CInlineAction) 
282      * @see runAction
283      */
284     public function runActionWithFilters($action,$filters)
285     {
286         if(empty($filters))
287             $this->runAction($action);
288         else
289         {
290             $priorAction=$this->_action;
291             $this->_action=$action;
292             CFilterChain::create($this,$action,$filters)->run();

#11  +– X:\home\fblood\www\framework\web\CController.php(266): 
CController->runActionWithFilters(CInlineAction, array()) 
261         {
262             if(($parent=$this->getModule())===null)
263                 $parent=Yii::app();
264             if($parent->beforeControllerAction($this,$action))
265             {
266                 $this->runActionWithFilters($action,$this->filters());
267                 $parent->afterControllerAction($this,$action);
268             }
269         }
270         else
271             $this->missingAction($actionID);

#12  +– X:\home\fblood\www\framework\web\CWebApplication.php(276): 
CController->run("login") 
271         {
272             list($controller,$actionID)=$ca;
273             $oldController=$this->_controller;
274             $this->_controller=$controller;
275             $controller->init();
276             $controller->run($actionID);
277             $this->_controller=$oldController;
278         }
279         else
280             throw new CHttpException(404,Yii::t('yii','Unable to resolve 
the request "{route}".',
281                 
array('{route}'=>$route===''?$this->defaultController:$route)));

#13  +– X:\home\fblood\www\framework\web\CWebApplication.php(135): 
CWebApplication->runController("site/login") 
130             foreach(array_splice($this->catchAllRequest,1) as $name=>$value)
131                 $_GET[$name]=$value;
132         }
133         else
134             $route=$this->getUrlManager()->parseUrl($this->getRequest());
135         $this->runController($route);
136     }
137 
138     /**
139      * Registers the core application components.
140      * This method overrides the parent implementation by registering 
additional core components.

#14  +– X:\home\fblood\www\framework\base\CApplication.php(162): 
CWebApplication->processRequest() 
157      */
158     public function run()
159     {
160         if($this->hasEventHandler('onBeginRequest'))
161             $this->onBeginRequest(new CEvent($this));
162         $this->processRequest();
163         if($this->hasEventHandler('onEndRequest'))
164             $this->onEndRequest(new CEvent($this));
165     }
166 
167     /**

#15  +– X:\home\fblood\www\index.php(13): CApplication->run() 
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();

2012-01-18 00:06:16 Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8k PHP/5.3.3 
Yii Framework/1.1.9 

Original issue reported on code.google.com by murtazin...@gmail.com on 17 Jan 2012 at 6:09

GoogleCodeExporter commented 9 years ago
i get the same error too. i have database prefix for my tables so that's maybe 
what's not getting handled well

Original comment by dopamine...@gmail.com on 30 Jan 2012 at 9:29

GoogleCodeExporter commented 9 years ago
I forget how do i clean this issue...
Try to check all chain of yii database access.
I remember, that i made some mistakes in database names in config files.

Original comment by murtazin...@gmail.com on 30 Jan 2012 at 6:35

GoogleCodeExporter commented 9 years ago
i get the same error too.

Original comment by usta...@gmail.com on 11 Feb 2012 at 10:17

GoogleCodeExporter commented 9 years ago
Checking. Please review your installation. If I can't reproduce this then I'm 
gonna close this report.

Original comment by bigch...@gmail.com on 23 Feb 2012 at 11:07