Good day .. I am having a problem here to retrieve data from certain column in db using yii framework.. I am a complete newbie to yii, but still managing,
I read lot of posts, forums and YouTube but none are working for me to get data from db as I want it, any help is much appreciated!
When it comes to authenticating users, its perfect. But when normally trying to retrieve other data than user authentication. I keep getting Error 500
Trying to get property of non-object
and stuff.
So using the authentication method in SiteControler, I took advantage in the $model
.. and re used it for my purpose:
$user = $model->username;
here username is perfectly giving me the value of username logged in.
But when I try to point from username to check another column in the same row called "UserAuth". It doesn't work!
I think logically, it should be like this:
$model->username->UserAuth;
Am I right? even when I add $this->UserAuth
its still the same!!
The column I want to check is called "UserAuth" in my table called "logins".. So matching the username, was successful, but the same method I used didn't work for checking other column. Hope I gave a clear pic here.
I am using yii 1 not 2, if that help (don't know the difference through)
Again to point that, I am new to web development era .. I used to do basic java SE .. but web seems different!
You tried
$model->username->UserAuth;
and
$this->UserAuth
But what you need to do is:
$model->UserAuth;
The $model
represents a row in the database. Each column is accessed as a separate property.
$model->username;
$model->UserAuth;
$model->anotherColumn;
$model->yetAnotherColumn;
This, of course, assumes that $model
is an object whose class extends CActiveRecord
. Without seeing more of your code, I can't be sure that it is or not.