ok, i imagine this might be a very newbish question.
I want to know if its possible to add a function to change the username in the build in yii user auth system?
i mean i don’t want to change the username in the demo, i want the user to be able to change his username after he has registered, but im worried that yii references the username as the userid, and thus will not allow to change it later on?
i mean change it in the users database, not the session database.
the question im asking is
does yii rely on the username, or the user id to reference the user?
for example a user register’s, posts a comment, and then changes his name.
edit:
Yii::app()->user->id gives me the username of the user, what to do so that it gives me the id of the user? (and how to use id as the id instead of the username?)
another little question if you don’t mind (i don’t want to make another thread, im making too many already), i notice that you made this skeleton app (nice job), but how do i make the app use the “users” database table instead of the “User” database table?
edit:
ok i made it work, by changing the name of models/User.php to models/Users.php and its name to (in the User.php file)
Users extends CActiveRecord {
and this bit
$record = User::model()->find($criteria);
to
$record = Users::model()->find($criteria);
thats all well and good, but i have been trying to add it for the last couple of days, and i can’t figure out where i need to add
tableName()
i dont know what piece of code i need to add in god knows what file…
everywhere it says
or something similar, no where does it say what the override the tableName() method is or how to override it…
edit:
finnaly!! finnaly do i find one useful reference to tableName()
as always, no one told or explained that to have a differently named table you need to add this in the models/yourmodel.php file
class yourmodel extends CActiveRecord
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'YOURDATABASETABLENAME';
}
is it that hard to simply give that small piece of text below the description of the tableName() method??
What can’t you understand from the line ‘{return} string: the tablename’? If the usage was presented for all methods, API would be a bloated, unusable mess of snippets.
There are better ways to improve the documentation I suppose.