Using 'AS' in CDbCriteria

Would anybody be able to post an example of using 'AS' in a CDbCriteria statement? I've been looking all over the documentation, and can't figure out how to give CDbCriteria an alias.

$cdbcriteria = array(

		'select'=>'id, name, city, state, smallsum, price, url, cat1, cat2, cat3, cat4, lat, lng',

		'alias'=>'(3959*acos(cos(radians(:baselat)) * cos(radians(lat))*cos(radians(lng)-radians(:baselng))+sin(radians(:baselat))*sin(radians(lat)))) AS distance',


	        'condition'=>'cat1 = :venue OR cat2 = :venue OR cat3 = :venue OR cat4 = :venue',

		'having'=>'distance <= :rnge',





That's the last thing I tried (and it didn't work).

You misunderstood alias. The 'alias' option here is for table alias. You can directly put your aliased columns in the 'select' option. Just make sure you declare 'distance' class member.

If you use column aliases directly in the select option, why does the query still select the same column again with a default alias?

$criteria->alias = ‘MyTable’;

$criteria->select = ‘ AS id’;


SELECT AS id, AS t0_c0