Hi im new in yii … i wish to retrieve data from db and then view data in drop down menu (selection box). How to do that ? please help thanks
Hi im new in yii … i wish to retrieve data from db and then view data in drop down menu (selection box). How to do that ? please help thanks
can u pls be specific to answer me how to retrieve data from db ?
The answers on this questions is written in documentation. There is not so much menu items to be a scientists to read it. http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder
$user = Yii::app()->db->createCommand()
->select('username, password')
->from('tbl_user')
->where('id=:id', array(':id'=>1))
->queryRow();
found this code … is this correct ?
Too "complicated’. You’ld rather write:
$user=User::model()->findByPk(1);
if($user===null) {
throw new CException('No user'); // Or handle error differently.
} else {
$username=$user->username;
$password=$user->password;
}
Prior to that you have to generate the User model for the ‘tbl_user’ table using the methods that are described in the tutorials, documentation, … .