Access Rules On Yii

Im having trouble with my access rules in my controller. Im retrieving list of pages from my database in an array form.

Im using this PDO stement to get the list of pages that can be accessed by my user.

public function getPage() {

    $user = CHtml::encode(Yii::app()->user->name);





    include 'DbHandler.class.php';





    $connectionString[0] = Yii::app()->params['dbhandler'];


    $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;


}





    $this->access = $yourarrayname;

so I store my array list of pages in a variable called $this->access but when I use the $this->access, I can still access other pages which is not even listed in my database.

here is my usage of $this->access in accessRules():

public function accessRules() {

    if ($this->user == 'Guest') {


        $this->user = 'admin';


    }


    $this->getPage();





    return array(


        array('allow', // allow authenticated user to perform 'create' and 'update' actions


            'actions' => array('show', 'show'),


            'users' => array('@'),


        ),


        array('allow', // allow admin user to perform 'admin' and 'delete' actions


            'actions' => array('admin', 'delete', "register"),


            'users' => array('gago'),


        ),


        array('allow', // allow admin user to perform 'admin' and 'delete' actions


            'actions' => $this->access,


            'users' => array("admin"),


        ),


        array('deny', // deny all users


            'users' => array('*'),


        ),


    );


}

Any solution for this, or do you encounter the same situations like this?

I just solved this problem,

I changed my PDO statement to:

public function fetchArrayData()

{

   return $this->_stmt->fetchAll(PDO::FETCH_COLUMN, 0);

}

And this is my getPage function:

public function getPage() {

    $user = CHtml::encode(Yii::app()->user->name);





    include 'DbHandler.class.php';





    $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->access = $dbhandler3->fetchArrayData();


    


}