I have ported entire code from another project to my new Yii 1.1.12 project. It original one, anything worked just fine.

In my new project (though I touched nothing in login area) any attempt to display login form (or request to any action, that requires user to be logged in) ends in Login model attempting to actually login user.

When I request any action, that requires login, Yii "internals" redirect me to actionLogin of my main site controller. But, instead of login form being rendered, I'm getting a bit strange exception:

CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'login' in 'where clause'. The SQL statement executed was: SELECT * FROM `users` `t` WHERE LOWER(login)=? LIMIT 1

Some internal tests proven, that first line of my loginAction() in my site controller:

    $model = new Login;

causes actual attempt to login user. Has anyone got any idea, what is going on here?

I have never run into situation, in any of my Yii projects, that creation of Login model actually attempts to login user, when $_POST is empty (no form was ever rendered, so no POST data was ever submitted) and when user code does not execute $model->login().

Edit: This is a standard Yii method (though still mysterious to me), so I asked another question on this.

Can anyone help here or advice, what could be wrong, or what am I missing?

Was it helpful?


Since my model's Name is Login, then login() method defined in it, acts for PHP as constructor.

This has nothing to do with Yii, this is a base PHP behavior, inherited from old, bad PHP4 and depracated as of PHP 5.3.3 only in case of namespaced classes. When class definition does not use namespace, this behavior (defining constructor as function named the same way as class) is still valid.

See this answer for more details or refer to PHP manual.

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