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
How to get PK id of a table in Yii framework?
Вопрос
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
Нет правильного решения
Другие советы
Не связан с StackOverflow