cleaning up some code.
This commit is contained in:
parent
aed1443bf1
commit
0f2d311739
|
@ -222,8 +222,7 @@ protected function execute($sql, $bindings = array())
|
|||
|
||||
// Once we have execute the query, we log the SQL, bindings, and
|
||||
// execution time in a static array that is accessed by all of
|
||||
// the connections used by the application. This allows us to
|
||||
// review all of the executed SQL.
|
||||
// the connections used by the application.
|
||||
$this->log($sql, $bindings, $time);
|
||||
|
||||
return array($statement, $result);
|
||||
|
|
|
@ -399,7 +399,7 @@ protected function where_nested($callback, $connector)
|
|||
|
||||
// To handle a nested where statement, we will actually instantiate a
|
||||
// new Query instance and run the callback over that instance, which
|
||||
// will allow the developer to have a fresh query to work with.
|
||||
// will allow the developer to have a fresh query.
|
||||
$query = new Query($this->connection, $this->grammar, $this->from);
|
||||
|
||||
// Once the callback has been run on the query, we will store the
|
||||
|
@ -623,8 +623,7 @@ public function get($columns = array('*'))
|
|||
|
||||
// If the query has an offset and we are using the SQL Server grammar,
|
||||
// we need to spin through the results and remove the "rownum" from
|
||||
// each of the objects. Unfortunately SQL Server does not have an
|
||||
// offset keyword, so we have to use row numbers in the query.
|
||||
// each of the objects since there is no "offset".
|
||||
if ($this->offset > 0 and $this->grammar instanceof SQLServer)
|
||||
{
|
||||
array_walk($results, function($result)
|
||||
|
|
|
@ -35,17 +35,16 @@ public static function execute($table)
|
|||
|
||||
$grammar = static::grammar($connection);
|
||||
|
||||
// Each grammar has a function that corresponds to the command type
|
||||
// and is responsible for building that's commands SQL. This lets
|
||||
// the SQL generation stay very granular and makes it simply to
|
||||
// add new database systems to the schema system.
|
||||
// Each grammar has a function that corresponds to the command type and is for
|
||||
// building that command's SQL. This lets the SQL generation stay granular
|
||||
// and flexible across various database systems.
|
||||
if (method_exists($grammar, $method = $command->type))
|
||||
{
|
||||
$statements = $grammar->$method($table, $command);
|
||||
|
||||
// Once we have the statements, we will cast them to an array
|
||||
// even though not all of the commands return an array just
|
||||
// in case the command needs to run more than one query.
|
||||
// Once we have the statements, we will cast them to an array even though
|
||||
// not all of the commands return an array just in case the command
|
||||
// needs multiple queries to complete its database work.
|
||||
foreach ((array) $statements as $statement)
|
||||
{
|
||||
$connection->statement($statement);
|
||||
|
@ -62,10 +61,9 @@ public static function execute($table)
|
|||
*/
|
||||
protected static function implications($table)
|
||||
{
|
||||
// If the developer has specified columns for the table and the
|
||||
// table is not being created, we will assume they simply want
|
||||
// to add the columns to the table, and will generate an add
|
||||
// command on the schema automatically.
|
||||
// If the developer has specified columns for the table and the table is
|
||||
// not being created, we'll assume they simply want to add the columns
|
||||
// to the table and generate the add command.
|
||||
if (count($table->columns) > 0 and ! $table->creating())
|
||||
{
|
||||
$command = new Fluent(array('type' => 'add'));
|
||||
|
@ -73,9 +71,9 @@ protected static function implications($table)
|
|||
array_unshift($table->commands, $command);
|
||||
}
|
||||
|
||||
// For some extra syntax sugar, we'll check for any implicit
|
||||
// indexes on the table since the developer may specify the
|
||||
// index type on the fluent column declaration.
|
||||
// For some extra syntax sugar, we'll check for any implicit indexes
|
||||
// on the table since the developer may specify the index type on
|
||||
// the fluent column declaration for convenience.
|
||||
foreach ($table->columns as $column)
|
||||
{
|
||||
foreach (array('primary', 'unique', 'fulltext', 'index') as $key)
|
||||
|
|
|
@ -23,14 +23,14 @@ public function create(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = implode(', ', $this->columns($table));
|
||||
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than auto
|
||||
// incrementing keys, no indexes will be created during the first creation
|
||||
// of the table as they're added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
// MySQL supports various "engines" for database tables. If an engine ws specified
|
||||
// by the developer, we will set it after adding the columns the table creation
|
||||
// statement. Some engines support extra indexes.
|
||||
// MySQL supports various "engines" for database tables. If an engine was
|
||||
// specified by the developer, we will set it after adding the columns
|
||||
// the table creation statement the schema.
|
||||
if ( ! is_null($table->engine))
|
||||
{
|
||||
$sql .= ' ENGINE = '.$table->engine;
|
||||
|
@ -50,9 +50,9 @@ public function add(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the
|
||||
// front of each definition, then we'll concatenate the definitions
|
||||
// using commas like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD '.$column;
|
||||
|
|
|
@ -16,9 +16,9 @@ public function create(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = implode(', ', $this->columns($table));
|
||||
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than auto
|
||||
// incrementing keys, no indexes will be created during the first creation
|
||||
// of the table as they're added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
return $sql;
|
||||
|
@ -35,9 +35,9 @@ public function add(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the
|
||||
// front of each definition, then we'll concatenate the definitions
|
||||
// using commas like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD COLUMN '.$column;
|
||||
|
|
|
@ -53,18 +53,18 @@ public function add(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the
|
||||
// front of each definition, then we'll concatenate the definitions
|
||||
// using commas like normal and generate the SQL.
|
||||
$columns = array_map(function($column)
|
||||
{
|
||||
return 'ADD COLUMN '.$column;
|
||||
|
||||
}, $columns);
|
||||
|
||||
// SQLite only allows one column to be added in an ALTER statement, so we
|
||||
// will create an array of statements and return them all to the schema
|
||||
// manager, which will execute each one separately.
|
||||
// SQLite only allows one column to be added in an ALTER statement,
|
||||
// so we will create an array of statements and return them all to
|
||||
// the schema manager for separate execution.
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$sql[] = 'ALTER TABLE '.$this->wrap($table).' '.$column;
|
||||
|
|
|
@ -23,9 +23,9 @@ public function create(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = implode(', ', $this->columns($table));
|
||||
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than auto
|
||||
// incrementing keys, no indexes will be created during the first creation
|
||||
// of the table as they're added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
return $sql;
|
||||
|
@ -42,9 +42,9 @@ public function add(Table $table, Fluent $command)
|
|||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the
|
||||
// front of each definition, then we'll concatenate the definitions
|
||||
// using commas like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD '.$column;
|
||||
|
|
|
@ -285,7 +285,7 @@ public function send_headers()
|
|||
|
||||
// Once the framework controlled headers have been sentm, we can
|
||||
// simply iterate over the developer's headers and send each one
|
||||
// to the browser. Headers with the same name will be overriden.
|
||||
// back to the browser for the response.
|
||||
foreach ($this->headers as $name => $value)
|
||||
{
|
||||
header("{$name}: {$value}", true);
|
||||
|
|
|
@ -213,7 +213,7 @@ public function render()
|
|||
//
|
||||
// Also, if the Blade view has expired or doesn't exist it will be
|
||||
// re-compiled and placed in the view storage directory. The Blade
|
||||
// views are re-compiled each time the original view is changed.
|
||||
// views are re-compiled the original view changes.
|
||||
if (strpos($this->path, BLADE_EXT) !== false)
|
||||
{
|
||||
$this->path = $this->compile();
|
||||
|
|
Loading…
Reference in New Issue