"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/rbac/migrations/m200409_110543_rbac_update_mssql_trigger.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

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

m200409_110543_rbac_update_mssql_trigger.php  (yii2-2.0.35):m200409_110543_rbac_update_mssql_trigger.php  (yii2-2.0.36)
skipping to change at line 44 skipping to change at line 44
return $authManager; return $authManager;
} }
protected function findForeignKeyName($table, $column, $referenceTable, $ref erenceColumn) protected function findForeignKeyName($table, $column, $referenceTable, $ref erenceColumn)
{ {
return (new Query()) return (new Query())
->select(['OBJECT_NAME(fkc.constraint_object_id)']) ->select(['OBJECT_NAME(fkc.constraint_object_id)'])
->from(['fkc' => 'sys.foreign_key_columns']) ->from(['fkc' => 'sys.foreign_key_columns'])
->innerJoin(['c' => 'sys.columns'], 'fkc.parent_object_id = c.object _id AND fkc.parent_column_id = c.column_id') ->innerJoin(['c' => 'sys.columns'], 'fkc.parent_object_id = c.object _id AND fkc.parent_column_id = c.column_id')
->innerJoin(['r' => 'sys.columns'], 'fkc.referenced_object_id = r.ob ject_id AND fkc.referenced_column_id = r.column_id') ->innerJoin(['r' => 'sys.columns'], 'fkc.referenced_object_id = r.ob ject_id AND fkc.referenced_column_id = r.column_id')
->where( ->andWhere('fkc.parent_object_id=OBJECT_ID(:fkc_parent_object_id)',[
[ ':fkc_parent_object_id' => $this->db->schema->getRawTableName($table)])
'AND', ->andWhere('fkc.referenced_object_id=OBJECT_ID(:fkc_referenced_objec
['fkc.parent_object_id' => $this->db->schema->getRawTableNam t_id)',[':fkc_referenced_object_id' => $this->db->schema->getRawTableName($refer
e($table)], enceTable)])
['fkc.referenced_object_id' => $this->db->schema->getRawTabl ->andWhere(['c.name' => $column])
eName($referenceTable)], ->andWhere(['r.name' => $referenceColumn])
['c.name' => $column], ->scalar($this->db);
['r.name' => $referenceColumn],
]
)->scalar($this->db);
} }
/** /**
* @return bool * @return bool
*/ */
protected function isMSSQL() protected function isMSSQL()
{ {
return $this->db->driverName === 'mssql' || $this->db->driverName === 's qlsrv' || $this->db->driverName === 'dblib'; return $this->db->driverName === 'mssql' || $this->db->driverName === 's qlsrv' || $this->db->driverName === 'dblib';
} }
skipping to change at line 74 skipping to change at line 70
* {@inheritdoc} * {@inheritdoc}
*/ */
public function up() public function up()
{ {
if ($this->isMSSQL()) { if ($this->isMSSQL()) {
$authManager = $this->getAuthManager(); $authManager = $this->getAuthManager();
$this->db = $authManager->db; $this->db = $authManager->db;
$schema = $this->db->getSchema()->defaultSchema; $schema = $this->db->getSchema()->defaultSchema;
$triggerSuffix = $this->db->schema->getRawTableName($authManager->it emChildTable); $triggerSuffix = $this->db->schema->getRawTableName($authManager->it emChildTable);
$this->execute("DROP TRIGGER {$schema}.trigger_{$triggerSuffix};"); $this->execute("IF (OBJECT_ID(N'{$schema}.trigger_{$triggerSuffix}')
IS NOT NULL) DROP TRIGGER {$schema}.trigger_{$triggerSuffix};");
$this->execute("IF (OBJECT_ID(N'{$schema}.trigger_auth_item_child')
IS NOT NULL) DROP TRIGGER {$schema}.trigger_auth_item_child;");
$this->execute("CREATE TRIGGER {$schema}.trigger_delete_{$triggerSuf fix} $this->execute("CREATE TRIGGER {$schema}.trigger_delete_{$triggerSuf fix}
ON {$schema}.{$authManager->itemTable} ON {$schema}.{$authManager->itemTable}
INSTEAD OF DELETE INSTEAD OF DELETE
AS AS
BEGIN BEGIN
DELETE FROM {$schema}.{$authManager->itemChildTable} WHERE par ent IN (SELECT name FROM deleted) OR child IN (SELECT name FROM deleted); DELETE FROM {$schema}.{$authManager->itemChildTable} WHERE par ent IN (SELECT name FROM deleted) OR child IN (SELECT name FROM deleted);
DELETE FROM {$schema}.{$authManager->itemTable} WHERE name IN (SELECT name FROM deleted); DELETE FROM {$schema}.{$authManager->itemTable} WHERE name IN (SELECT name FROM deleted);
END;" END;"
); );
 End of changes. 2 change blocks. 
12 lines changed or deleted 12 lines changed or added

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