This is code query data from database :
public function getAllUser(){
$connect = Yii::app()->db;
$query = "SELECT * FROM user";
$statement = $connect->CreateCommand($query);
$result = $statement->query();
return $result;
}
After that I use Controller to get data & send to View :
public function actionIndex()
{
$consultas = new ConsultasDB();
$listUser = $consultas->getAllUser();
$this->render('index', array
("listUser" => $listUser));
}
In View I know show all information from database by loop listUser
foreach ($listUser->readAll() as $user)
{
echo 'Username : '.$user["username"].'<br>';
echo 'Password : '.$user["password"].'<br>';
}
but I don't know how to get a object with an index. Ex: User[1]... Thanks!