framework/db/schema/mssql/CMssqlCommandBuilder.php
public function createUpdateCommand($table,$data,$criteria)
	{
		$criteria=$this->checkCriteria($table,$criteria);
		$fields=array();
		$values=array();
		$bindByPosition=isset($criteria->params[0]);
		$i=0;
		foreach($data as $name=>$value)
		{
			if(($column=$table->getColumn($name))!==null)
			{
				if ($table->sequenceName !== null && $column->isPrimaryKey === true) continue;
				if ($column->dbType === 'timestamp') continue;
				if($value instanceof CDbExpression)
				{
					$fields[]=$column->rawName.'='.$value->expression;
					foreach($value->params as $n=>$v)
						$values[$n]=$v;
				}
				elseif($bindByPosition)
				{
					$fields[]=$column->rawName.'=?';
					$values[]=$column->typecast($value);
				}
				else
				{
					$fields[]=$column->rawName.'='.self::PARAM_PREFIX.$i;
					$values[self::PARAM_PREFIX.$i]=$column->typecast($value);
					$i++;
				}
			}
		}
		if($fields===array())
			throw new CDbException(Yii::t('yii','No columns are being updated for table "{table}".',
				array('{table}'=>$table->name)));
		$sql="UPDATE {$table->rawName} SET ".implode(', ',$fields);
		$sql=$this->applyJoin($sql,$criteria->join);
		$sql=$this->applyCondition($sql,$criteria->condition);
		$sql=$this->applyOrder($sql,$criteria->order);
		$sql=$this->applyLimit($sql,$criteria->limit,$criteria->offset);

		$command=$this->getDbConnection()->createCommand($sql);
		$this->bindValues($command,array_merge($values,$criteria->params));

		return $command;
	}
public function createUpdateCommand($table,$data,$criteria)
	{
		$criteria=$this->checkCriteria($table,$criteria);
		$fields=array();
		$values=array();
		$bindByPosition=isset($criteria->params[0]);
		$i=0;
		foreach($data as $name=>$value)
		{
			if(($column=$table->getColumn($name))!==null)
			{
				if ($table->sequenceName !== null && $column->isPrimaryKey === true) continue;
				if ($column->dbType === 'timestamp') continue;
				if($value instanceof CDbExpression)
				{
					$fields[]=$column->rawName.'='.$value->expression;
					foreach($value->params as $n=>$v)
						$values[$n]=$v;
				}
				elseif($bindByPosition)
				{
					$fields[]=$column->rawName.'=?';
					$values[]=$column->typecast($value);
				}
				else
				{
					$fields[]=$column->rawName.'='.self::PARAM_PREFIX.$i;
					$values[self::PARAM_PREFIX.$i]=$column->typecast($value);
					$i++;
				}
			}
		}
		if($fields===array())
			throw new CDbException(Yii::t('yii','No columns are being updated for table "{table}".',
				array('{table}'=>$table->name)));
		$sql="UPDATE {$table->rawName} SET ".implode(', ',$fields);
		$sql=$this->applyJoin($sql,$criteria->join);
		$sql=$this->applyCondition($sql,$criteria->condition);
		$sql=$this->applyOrder($sql,$criteria->order);
		$sql=$this->applyLimit($sql,$criteria->limit,$criteria->offset);

		$command=$this->getDbConnection()->createCommand($sql);
		$this->bindValues($command,array_merge($values,$criteria->params));

		return $command;
	}
public function createUpdateCommand ( $ table , $ data , $ criteria ) { $ criteria = $ this -> checkCriteria ( $ table , $ criteria ) ; $ fields = array ( ) ; $ values = array ( ) ; $ bindByPosition = isset ( $ criteria -> params [ 0 ] ) ; $ i = 0 ; foreach ( $ data as $ name => $ value ) { if ( ( $ column = $ table -> getColumn ( $ name ) ) !== null ) { if ( $ table -> sequenceName !== null && $ column -> isPrimaryKey === true ) continue ; if ( $ column -> dbType === 'timestamp' ) continue ; if ( $ value instanceof CDbExpression ) { $ fields [ ] = $ column -> rawName . '=' . $ value -> expression ; foreach ( $ value -> params as $ n => $ v ) $ values [ $ n ] = $ v ; } elseif ( $ bindByPosition ) { $ fields [ ] = $ column -> rawName . '=?' ; $ values [ ] = $ column -> typecast ( $ value ) ; } else { $ fields [ ] = $ column -> rawName . '=' . self :: PARAM_PREFIX . $ i ; $ values [ self :: PARAM_PREFIX . $ i ] = $ column -> typecast ( $ value ) ; $ i ++ ; } } } if ( $ fields === array ( ) ) throw new CDbException ( Yii :: t ( 'yii' , 'No columns are being updated for table "{table}".' , array ( '{table}' => $ table -> name ) ) ) ; $ sql = "UPDATE {$table->rawName} SET " . implode ( ', ' , $ fields ) ; $ sql = $ this -> applyJoin ( $ sql , $ criteria -> join ) ; $ sql = $ this -> applyCondition ( $ sql , $ criteria -> condition ) ; $ sql = $ this -> applyOrder ( $ sql , $ criteria -> order ) ; $ sql = $ this -> applyLimit ( $ sql , $ criteria -> limit , $ criteria -> offset ) ; $ command = $ this -> getDbConnection ( ) -> createCommand ( $ sql ) ; $ this -> bindValues ( $ command , array_merge ( $ values , $ criteria -> params ) ) ; return $ command ; }
Creates an UPDATE command.
Override parent implementation because mssql don't want to update an identity column
@param CDbTableSchema $table the table metadata
@param array $data list of columns to be updated (name=>value)
@param CDbCriteria $criteria the query criteria
@throws CDbException if no columns are being updated
@return CDbCommand update command.
Creates an UPDATE command . Override parent implementation because mssql don t want to update an identity column