Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

` symbol should be added to wrap column name when creating sql #3084

Closed
lubobill1990 opened this Issue · 1 comment

2 participants

@lubobill1990

The function createFindCommand in class CDbCommandBuilder response for the creation of SELECT command based on CDbCriteria.

$select=is_array($criteria->select) ? implode(', ',$criteria->select) : $criteria->select;

But, when we use reserved word of DBMS, 'key' in mysql for example, as column name, the columsn name should be wrapped with ` to avoid sql syntax error.

It should be written as:

$select=is_array($criteria->select) ? implode('`, `',$criteria->select) : $criteria->select;
if(trim($select) != '*'){
    $select="`$select`";
}
@cebe
Collaborator

Duplicate of #2176 and #2525. This issue can not be fixed because CDbCriteria is not aware of the underlying database system. This problem has been resolved in yii 2.

@cebe cebe closed this
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.