"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/db/mssql/QueryBuilder.php" between
yii2-2.0.36.tar.gz and yii2-2.0.37.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

QueryBuilder.php  (yii2-2.0.36):QueryBuilder.php  (yii2-2.0.37)
skipping to change at line 450 skipping to change at line 450
* OUTPUT clause - The OUTPUT clause is new to SQL Server 2005 and has the a bility to access * OUTPUT clause - The OUTPUT clause is new to SQL Server 2005 and has the a bility to access
* the INSERTED and DELETED tables as is the case with a trigger. * the INSERTED and DELETED tables as is the case with a trigger.
*/ */
public function insert($table, $columns, &$params) public function insert($table, $columns, &$params)
{ {
$columns = $this->normalizeTableRowData($table, $columns, $params); $columns = $this->normalizeTableRowData($table, $columns, $params);
$version2005orLater = version_compare($this->db->getSchema()->getServerV ersion(), '9', '>='); $version2005orLater = version_compare($this->db->getSchema()->getServerV ersion(), '9', '>=');
list($names, $placeholders, $values, $params) = $this->prepareInsertValu es($table, $columns, $params); list($names, $placeholders, $values, $params) = $this->prepareInsertValu es($table, $columns, $params);
return 'INSERT INTO ' . $this->db->quoteTableName($table)
$sql = 'INSERT INTO ' . $this->db->quoteTableName($table)
. (!empty($names) ? ' (' . implode(', ', $names) . ')' : '') . (!empty($names) ? ' (' . implode(', ', $names) . ')' : '')
. ($version2005orLater ? ' OUTPUT INSERTED.*' : '') . ($version2005orLater ? ' OUTPUT INSERTED.* INTO @temporary_inserte d' : '')
. (!empty($placeholders) ? ' VALUES (' . implode(', ', $placeholders ) . ')' : $values); . (!empty($placeholders) ? ' VALUES (' . implode(', ', $placeholders ) . ')' : $values);
if ($version2005orLater) {
$schema = $this->db->getTableSchema($table);
$cols = [];
foreach ($schema->columns as $column) {
$cols[] = $this->db->quoteColumnName($column->name) . ' '
. $column->dbType
. (in_array($column->dbType, ['char', 'varchar', 'nchar', 'n
varchar', 'binary', 'varbinary']) ? "(MAX)" : "")
. ' ' . ($column->allowNull ? "NULL" : "");
}
$sql = "SET NOCOUNT ON;DECLARE @temporary_inserted TABLE (" . implod
e(", ", $cols) . ");" . $sql . ";SELECT * FROM @temporary_inserted";
}
return $sql;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
* @see https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact -sql * @see https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact -sql
* @see http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condi tion-With-MERGE.aspx * @see http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condi tion-With-MERGE.aspx
*/ */
public function upsert($table, $insertColumns, $updateColumns, &$params) public function upsert($table, $insertColumns, $updateColumns, &$params)
{ {
/** @var Constraint[] $constraints */ /** @var Constraint[] $constraints */
 End of changes. 3 change blocks. 
2 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)