Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

CDbCriteria column name don't use quote #2525

Closed
hiscaler opened this Issue · 3 comments

2 participants

@hiscaler

Like follow code

 $criteria->addBetweenCondition('year_month', "{$this->year}01", "{$this->year}12");

will generate like this SQL

SELECT COUNT(*) FROM `www_monthly_reports` `t` WHERE (project_id=1) AND (year_month BETWEEN 201301 AND 201312)

because year_month is reserverd words in SQL, so go wrong when you execute it IN Yii 1.1.13

@cebe
Owner

This can not be fixed as CDbCriteria is not aware of the underlying database system it does not know how to quote, you have to do it yourself.
This problem has been fixed in Yii2 but can not be changed in 1.1

@cebe cebe closed this
@hiscaler

CDbCriteria is not aware of the underlying database system? use quoteColumnName and quoteValue can't fixed this problem?

@cebe
Owner

You can use them youself, but CDbCriteria can not do that itself, because you can create criteria without needing a db connection:

$c = new CDbCriteria();

It is then not aware of any context, so it does not know where to call quoteColumnName.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.