Yii Framework Forum: CDbCriteria - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CDbCriteria alias Rate Topic: -----

#1 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 05 March 2010 - 08:58 AM

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.
0

#2 User is offline   jayrulez 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 348
  • Joined: 29-July 09

Posted 05 March 2010 - 11:11 AM

View Postrohit, 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.


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.
0

#3 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

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!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users