I am new to yii. I am currently working on a yii project in which I want that when a user is logged in, and then submit there items, then how to show and manage that users there own items. not of other users.
Please anyone help me that how to use this kind of SQL query and where to place this query, i.e. either in controller or model or view ??
You should start with documentation, it’s all there.
Chapters to read carefully:
here is a sql query.
$user = Yii::app()->db->createCommand()
->select('id, username, profile')
->join('tbl_profile p', 'u.id=p.user_id')
Where I have to write this type of query in my code. i.e. either in model or controller or where ?
If you prefer to use DAO over AQ/AR then you’ll probably have no models, so you can do it in controller.
Actually, it’s up to you. Personally I prefer to use AR/RAR and store complex sql inside models, so that I can do something like
$data = MyModel::getSomethingTwisted($params);
BTW you’re posting to wrong forum, this one is for version 2 only.