Yii Framework Forum: Role is not working - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Role is not working Rate Topic: -----

#1 User is offline   neel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 133
  • Joined: 08-October 09

Posted 18 January 2010 - 08:57 AM

I upgrade Yii 1.0 to 1.1 but Role is not working. I got this error

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'User.id' in 'where clause'


#5 ../../components/Auth.php(13): CActiveFinder->find('User.id=?', Array)


Source File
../../yii/framework/db/CDbCommand.php(375)

00363: }
00364:
00365: if($this->_connection->enableProfiling)
00366: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00367:
00368: return $result;
00369: }
00370: catch(Exception $e)
00371: {
00372: if($this->_connection->enableProfiling)
00373: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00374: Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00375: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00376: array('{error}'=>$e->getMessage())));
00377: }
00378: }
00379: }


----
in my /component/Auth.php
$user=User::model()->with('role')->find('User.id=?',array(Yii::app()->user->getId()));

Do I need to change this line? Plz let me know.
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 18 January 2010 - 09:16 AM

View PostNeel, on 18 January 2010 - 08:57 AM, said:

I upgrade Yii 1.0 to 1.1 but Role is not working. I got this error
...
in my /component/Auth.php
$user=User::model()->with('role')->find('User.id=?',array(Yii::app()->user->getId()));

Do I need to change this line? Plz let me know.


Try t.id instead of User.id

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#3 User is offline   neel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 133
  • Joined: 08-October 09

Posted 18 January 2010 - 09:34 AM

Thanks Buddy. It's working. :rolleyes:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users