Last active
August 29, 2015 13:58
-
-
Save mageekguy/10017715 to your computer and use it in GitHub Desktop.
Using collection to find a table in a database and throwing an exception if the table already exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$database | |
->select(function($innerTable) use ($table) { return $table->getName() === $innerTable->getName(); }, 1, function() use ($table, $database) { | |
$database->add($table); | |
$table->setDatabase($database); | |
} | |
) | |
->apply(function($table) use ($database) { throw new database\exception('Table \'' . $table . '\' already exists in \'' . $database . '\''); }) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment