What is alias property used for?
while constructing a sql query, it by default uses `t` for main table. But I wanted to alias it.
But, $criteria->alias='user';
won't actually replace `t` in a query. Then how to use alias? and what is it for?
i'm using CActiveDataProvider to list down users. Does it affect anyway?
Regards.
Page 1 of 1
CDbCriteria alias
#2
Posted 05 March 2010 - 11:11 AM
rohit, on 05 March 2010 - 08:58 AM, said:
What is alias property used for?
while constructing a sql query, it by default uses `t` for main table. But I wanted to alias it.
But, $criteria->alias='user';
won't actually replace `t` in a query. Then how to use alias? and what is it for?
i'm using CActiveDataProvider to list down users. Does it affect anyway?
Regards.
while constructing a sql query, it by default uses `t` for main table. But I wanted to alias it.
But, $criteria->alias='user';
won't actually replace `t` in a query. Then how to use alias? and what is it for?
i'm using CActiveDataProvider to list down users. Does it affect anyway?
Regards.
You may use it to alias related tables;
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";
python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]
ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}
You say Tomato, I say Tomato.
#3
Posted 06 March 2010 - 12:53 AM
Yes I know that, I read docs. But the problem is, the query built is not reflecting the alias. It still uses `t` which is default!
Share this topic:
Page 1 of 1

Help












