saladha
(Sajeewanie2009)
1
$user=Users::model()->findAll('status=:status',array(':status'=>5));
using above code I need to get the
$user->email;
but it will give error
"Trying to get property of non-object "
can you tell me how do I get it;
in my model I have status and email attribute.I need get the all the email from the table where status =5
how do I get it pls help me.
That’s because findAll() returna ARRAY of values, not a single value.
Use find() if you want to get only one record.
Balu
(Mbalu123)
3
$user=Users::model()->findAll('status=:status',array(':status'=>5));
foreach($user as $user_1)
{
echo $user_1->email;
}
Try this…
saladha
(Sajeewanie2009)
4
can you tell me how do I get all the record not only one.
saladha
(Sajeewanie2009)
5
whaen it
echo $user_1->email it also display only one record.how do I get all the record of email column.pls help me
Balu
(Mbalu123)
6
according to your condition in find all there is only one record is present , If you want all record remove the condition in the findAll()
saladha
(Sajeewanie2009)
7
can you pls post the code for that.when remove the condition it will give the error
Balu
(Mbalu123)
9
$user=Users::model()->findAll();
foreach($user as $user_1)
{
echo $user_1->email;
}
Actually, you had a typo.
Should be
echo $user_1->email;