Im using a select sql statement PDO fetchData,
$user = 'admin';
sql = 'SELECT AccessPage FROM accessrights where UserName = '$user'';
in database the result would look like this:
-----------
Access Page
-----------
- index
+ create
- update
And I will store it inside a variable $result
How can I make the $result format to an array just like this?
$result = array('index','create','update');
Another question,
I used the codes in my function: but when I var_dump, it retun a array(0) { } value.
Here is my function:
$user = CHtml::encode(Yii::app()->user->name);
$connectionString[0] = Yii::app()->params['dbhandler2'];
$dbhandler3 = new DBHandler($connectionString[0]);
$dbhandler3->open();
$dbhandler3->prepare("SELECT AccessPage FROM accessrights where UserName ='$user'");
$dbhandler3->execute();
$this->result2 = $dbhandler3->fetchAllData();
$dbhandler3->close();
$yourarrayname = array();
while ($row = $dbhandler3->fetchAllData()) {
$yourarrayname[] = $row['AccessPage'];
}
$this->access = $yourarrayname;
use the below code