Skip to content

Commit

Permalink
Add stub methods for enabling/disabling foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 4, 2014
1 parent be8b966 commit 5de8eee
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,24 @@ public function rollbackSavepoint($name) {
$this->execute($this->_driver->rollbackSavePointSQL($name));
}

/**
* Run driver specific SQL to disable foreign key checks.
*
* @return void
*/
public function disableForeignKeys() {
$this->execute($this->_driver->disableForeignKeySql());
}

/**
* Run driver specific SQL to enable foreign key checks.
*
* @return void
*/
public function enableForeignKeys() {
$this->execute($this->_driver->enableForeignKeySql());
}

/**
* Executes a callable function inside a transaction, if any exception occurs
* while executing the passed callable, the transaction will be rolled back
Expand Down
12 changes: 12 additions & 0 deletions src/Database/Dialect/MysqlDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,16 @@ public function schemaDialect() {
return $this->_schemaDialect;
}

/**
* {@inheritDoc}
*/
public function disableForeignKeySQL() {
}

/**
* {@inheritDoc}
*/
public function enableForeignKeySQL() {
}

}
12 changes: 12 additions & 0 deletions src/Database/Dialect/PostgresDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,16 @@ public function schemaDialect() {
}
return $this->_schemaDialect;
}

/**
* {@inheritDoc}
*/
public function disableForeignKeySQL() {
}

/**
* {@inheritDoc}
*/
public function enableForeignKeySQL() {
}
}
12 changes: 12 additions & 0 deletions src/Database/Dialect/SqliteDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,16 @@ public function schemaDialect() {
return $this->_schemaDialect;
}

/**
* {@inheritDoc}
*/
public function disableForeignKeySQL() {
}

/**
* {@inheritDoc}
*/
public function enableForeignKeySQL() {
}

}
12 changes: 12 additions & 0 deletions src/Database/Dialect/SqlserverDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,16 @@ public function newCompiler() {
return new SqlserverCompiler();
}

/**
* {@inheritDoc}
*/
public function disableForeignKeySQL() {
}

/**
* {@inheritDoc}
*/
public function enableForeignKeySQL() {
}

}
14 changes: 14 additions & 0 deletions src/Database/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ public abstract function savePointSQL($name);
*/
public abstract function rollbackSavePointSQL($name);

/**
* Get the SQL for disabling foreign keys
*
* @return string
*/
public abstract function disableForeignKeySQL();

/**
* Get the SQL for enabling foreign keys
*
* @return string
*/
public abstract function enableForeignKeySQL();

/**
* Returns whether this driver supports save points for nested transactions
*
Expand Down

0 comments on commit 5de8eee

Please sign in to comment.