how to get the "as" values of cdbcriteria's select case?

I have a cdbcriteria query like e.g


    $criteria = new CDbCriteria();

    $criteria->select = array(

        'CASE

         when userid is not null then userid

        end

      as A',

        'CASE 

         when userid is not null then \'D\'

        end

      as H');

    $result = MyModel::model()->findAll($criteria);

when i foreach the $result, am getting objects in each of those results and I can only get the actual table column like e.g


$obj->USERID

I want to get the alias that i used in the select statement like e.g


$obj->A  OR $obj->H 



but if I do that, am getting an error, because A and H are not properties of the MyModel

is it possible to get the "as" names as table columns from the result of the findAll?, if so, how?

if you want to access the alias you have to define a property in your model before you access it


class MyModel extents CActiveRecord

{

       public $A;

       ....


}

thanks for the reply. It’s either am gonna do your suggestion OR will use the existing elastic search of the system.

but for the quick solution. I’ll stick with the native sql


    	$command = Yii::app()->db->createCommand($sql);

    	$dataReader = $command->query();

    	$result = $dataReader->readAll();    


and pagination


    	function PaginateArray($input, $page, $show_per_page) {

    	

    		$page = $page < 1 ? 1 : $page;

    	

    		$start = ($page - 1) * ($show_per_page);

    		$offset = $show_per_page;

    	

    		$outArray = array_slice($input, $start, $offset);

    	

			return $outArray;

    	}

good luck with that you probably have to roll your own pagination and stuff, try and look for an extension if you interacting with elastic make you life easier