diff --git a/CHANGELOG b/CHANGELOG index 4953f31e6..b8f600167 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ Version 1.1.8 work in progress - Enh #2268: Added CClientScript::getPackageBaseUrl() (Qiang) - Enh #2273: Used better merging algorithm to build query parameters that are of array type in CUrlManager (Qiang) - Enh #2299: Added CAssetManager.newFileMode and newDirMode (Qiang) +- Enh #2325: Added $option parameter to CDbCommand::select() to support special SELECT syntax (Qiang) - Enh: Added CHttpSession::regenerateID() and improved CWebUser::changeIdentity() by regenerating session ID (Qiang) - Enh: Added CActiveRecord::saveCounters() (Qiang) - Chg: Upgraded jQuery to 1.5.2 (Qiang) diff --git a/framework/db/CDbCommand.php b/framework/db/CDbCommand.php index 5ff2cd46b..1cc2748a5 100644 --- a/framework/db/CDbCommand.php +++ b/framework/db/CDbCommand.php @@ -572,10 +572,12 @@ class CDbCommand extends CComponent * Columns can contain table prefixes (e.g. "tbl_user.id") and/or column aliases (e.g. "tbl_user.id AS user_id"). * The method will automatically quote the column names unless a column contains some parenthesis * (which means the column contains a DB expression). + * @param string $option additional option that should be appended to the 'SELECT' keyword. For example, + * in MySQL, the option 'SQL_CALC_FOUND_ROWS' can be used. This parameter is supported since version 1.1.8. * @return CDbCommand the command object itself * @since 1.1.6 */ - public function select($columns='*') + public function select($columns='*', $option='') { if(is_string($columns) && strpos($columns,'(')!==false) $this->_query['select']=$columns; @@ -598,6 +600,8 @@ class CDbCommand extends CComponent } $this->_query['select']=implode(', ',$columns); } + if($option!='') + $this->_query['select']=$option.' '.$this->_query['select']; return $this; }