Yii Framework Forum: params wont replace in condition - Yii Framework Forum

Jump to content

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

params wont replace in condition Rate Topic: -----

#1 User is offline   N0-0ne 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-January 10

Posted 10 January 2010 - 04:51 AM

for some reason the params array wont replace the parameters I set in the conditions -
$Criteria = new CDbCriteria();
$Criteria->select = "{$this->title}, DAYOFMONTH({$this->date}) AS {$this->date}"; 
$Criteria->condition = "MONTH({$this->date}) = :month AND ({$this->date}) = :year ";
$Criteria->params = array(':month' => $this->month,':year' => $this->year);
$entries = CActiveRecord::model($this->dataProvider->modelClass)->findAll($Criteria);


when I check the log I see the query -
Querying SQL: SELECT title, DAYOFMONTH(createTime) AS createTime FROM `Entry` WHERE MONTH(createTime) = :month AND (createTime) = :year 


any one has any idea how to make this work ?
0

#2 User is offline   iGrog 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 09-October 09

Posted 10 January 2010 - 10:27 AM

In config/main.php in 'db' section add
      'enableParamLogging'=>true,

0

#3 User is offline   N0-0ne 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-January 10

Posted 10 January 2010 - 04:31 PM

Thanks it's working now.

another question.
is it possible to fetch data from the database to a non existent column name using AS.
as you can see from my query I give the DAYOFMONTH(createTime) the name createTime to get the data.
befor that I tried to give the column a diffrennt name, like "DAYOFMONTH(createTime) AS day", but it didn't fetch the column
in the results
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