How to retrieve data from db

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

All you need to read docs first

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.

$user = Yii::app()->db->createCommand()

->select('username, password')


->where('id=:id', array(':id'=>1))


found this code … is this correct ?

Too "complicated’. You’ld rather write:


if($user===null) {

   throw new CException('No user'); // Or handle error differently.

} else {




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, … .