Yii Framework Forum: Select ... AS newColumn with CDbCriteria? - Yii Framework Forum

Jump to content

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

Select ... AS newColumn with CDbCriteria? Rate Topic: -----

#1 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 569
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 February 2010 - 06:38 AM

Hi,

how can I create SELECT ... AS statements with a criteria?

like ...
$criteria->select = "CONCAT(a,B) AS c";

but this does not work.

Best regards,
schmunk
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#2 User is offline   PoL 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 506
  • Joined: 05-November 08
  • Location:Buenos Aires, Argentina

Posted 05 February 2010 - 07:24 AM

Did you try to declare a public variable in the model that uses that criteria? (in this case the variable must be called $c)
Don't say what you think, think what you say
The problem is communication! Excess of communication!
0

#3 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 569
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 February 2010 - 08:07 AM

No, I just wanted to do some custom things in my SELECT statement, I do not want a public variable for that.

Maybe I have to stick with this:
http://www.yiiframew...er#findAllBySql
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#4 User is offline   Sander 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 169
  • Joined: 03-November 09
  • Location:Amsterdam, Netherlands

Posted 05 February 2010 - 10:38 AM

You can probably do this with the combination of alias and CDbExpression.
0

#5 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 10 July 2010 - 02:12 PM

mmm you ever find a solution? am hitting against the same wall :) I dont see how alias or CDBExpression can help ?
0

#6 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 13 July 2010 - 03:28 AM

View PostPoL, on 05 February 2010 - 07:24 AM, said:

Did you try to declare a public variable in the model that uses that criteria? (in this case the variable must be called $c)

thanks Im having the same problem and now I can use the alias when I declared it as public variable on my model.. thanks a lot
0

#7 User is offline   reed1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 23-June 10

Posted 21 July 2010 - 10:55 PM

View PostPoL, on 05 February 2010 - 07:24 AM, said:

Did you try to declare a public variable in the model that uses that criteria? (in this case the variable must be called $c)


Don't know it was that easy lol, thanks
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