Question

Consider the following snippet
Here my table name is g_user

Yii::app()->user->id  returns as "admin"

    $criteria1=new CDbCriteria;
    $criteria1->select='g_user_id, name,email,e_role_id';
    $criteria1->condition='name ='."'".Yii::app()->user->id."'";
    $usr = User::model()->find($criteria1);
    echo "USER ID: ".$usr['g_user_id'];
    echo "NAME: ".$usr['name'];
    echo "EMAIL: ".$usr['email'];

The outcomes will be USER ID: NAME: admin EMAIL: test@gmail.com

What im trying to ask means "Why $usr['g_user_id'] returns empty value"? But it has value in database as 19. I dont know why. Please help to solve this issue

No correct solution

OTHER TIPS

It seems that there are more than one record with name = admin. Findbyattributes Return the first. Attention: Your code is not safe against sql injection

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top