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

Closed
lubobill1990 opened this Issue Dec 1, 2013 · 1 comment

Comments

2 participants

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`";
}
Owner

cebe commented Dec 1, 2013

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 closed this Dec 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment