You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2015/05/03 14:40:17 UTC
[37/51] [partial] airavata-php-gateway git commit: removing vendor
files
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
deleted file mode 100755
index 1fb9665..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
+++ /dev/null
@@ -1,2187 +0,0 @@
-<?php namespace Illuminate\Database\Query;
-
-use Closure;
-use Illuminate\Support\Collection;
-use Illuminate\Database\ConnectionInterface;
-use Illuminate\Database\Query\Grammars\Grammar;
-use Illuminate\Database\Query\Processors\Processor;
-
-class Builder {
-
- /**
- * The database connection instance.
- *
- * @var \Illuminate\Database\Connection
- */
- protected $connection;
-
- /**
- * The database query grammar instance.
- *
- * @var \Illuminate\Database\Query\Grammars\Grammar
- */
- protected $grammar;
-
- /**
- * The database query post processor instance.
- *
- * @var \Illuminate\Database\Query\Processors\Processor
- */
- protected $processor;
-
- /**
- * The current query value bindings.
- *
- * @var array
- */
- protected $bindings = array(
- 'select' => [],
- 'join' => [],
- 'where' => [],
- 'having' => [],
- 'order' => [],
- );
-
- /**
- * An aggregate function and column to be run.
- *
- * @var array
- */
- public $aggregate;
-
- /**
- * The columns that should be returned.
- *
- * @var array
- */
- public $columns;
-
- /**
- * Indicates if the query returns distinct results.
- *
- * @var bool
- */
- public $distinct = false;
-
- /**
- * The table which the query is targeting.
- *
- * @var string
- */
- public $from;
-
- /**
- * The table joins for the query.
- *
- * @var array
- */
- public $joins;
-
- /**
- * The where constraints for the query.
- *
- * @var array
- */
- public $wheres;
-
- /**
- * The groupings for the query.
- *
- * @var array
- */
- public $groups;
-
- /**
- * The having constraints for the query.
- *
- * @var array
- */
- public $havings;
-
- /**
- * The orderings for the query.
- *
- * @var array
- */
- public $orders;
-
- /**
- * The maximum number of records to return.
- *
- * @var int
- */
- public $limit;
-
- /**
- * The number of records to skip.
- *
- * @var int
- */
- public $offset;
-
- /**
- * The query union statements.
- *
- * @var array
- */
- public $unions;
-
- /**
- * The maximum number of union records to return.
- *
- * @var int
- */
- public $unionLimit;
-
- /**
- * The number of union records to skip.
- *
- * @var int
- */
- public $unionOffset;
-
- /**
- * The orderings for the union query.
- *
- * @var array
- */
- public $unionOrders;
-
- /**
- * Indicates whether row locking is being used.
- *
- * @var string|bool
- */
- public $lock;
-
- /**
- * The backups of fields while doing a pagination count.
- *
- * @var array
- */
- protected $backups = array();
-
- /**
- * The key that should be used when caching the query.
- *
- * @var string
- */
- protected $cacheKey;
-
- /**
- * The number of minutes to cache the query.
- *
- * @var int
- */
- protected $cacheMinutes;
-
- /**
- * The tags for the query cache.
- *
- * @var array
- */
- protected $cacheTags;
-
- /**
- * The cache driver to be used.
- *
- * @var string
- */
- protected $cacheDriver;
-
- /**
- * All of the available clause operators.
- *
- * @var array
- */
- protected $operators = array(
- '=', '<', '>', '<=', '>=', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
- '&', '|', '^', '<<', '>>',
- 'rlike', 'regexp', 'not regexp',
- );
-
- /**
- * Whether use write pdo for select.
- *
- * @var bool
- */
- protected $useWritePdo = false;
-
- /**
- * Create a new query builder instance.
- *
- * @param \Illuminate\Database\ConnectionInterface $connection
- * @param \Illuminate\Database\Query\Grammars\Grammar $grammar
- * @param \Illuminate\Database\Query\Processors\Processor $processor
- * @return void
- */
- public function __construct(ConnectionInterface $connection,
- Grammar $grammar,
- Processor $processor)
- {
- $this->grammar = $grammar;
- $this->processor = $processor;
- $this->connection = $connection;
- }
-
- /**
- * Set the columns to be selected.
- *
- * @param array $columns
- * @return $this
- */
- public function select($columns = array('*'))
- {
- $this->columns = is_array($columns) ? $columns : func_get_args();
-
- return $this;
- }
-
- /**
- * Add a new "raw" select expression to the query.
- *
- * @param string $expression
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function selectRaw($expression)
- {
- return $this->select(new Expression($expression));
- }
-
- /**
- * Add a new select column to the query.
- *
- * @param mixed $column
- * @return $this
- */
- public function addSelect($column)
- {
- $column = is_array($column) ? $column : func_get_args();
-
- $this->columns = array_merge((array) $this->columns, $column);
-
- return $this;
- }
-
- /**
- * Force the query to only return distinct results.
- *
- * @return $this
- */
- public function distinct()
- {
- $this->distinct = true;
-
- return $this;
- }
-
- /**
- * Set the table which the query is targeting.
- *
- * @param string $table
- * @return $this
- */
- public function from($table)
- {
- $this->from = $table;
-
- return $this;
- }
-
- /**
- * Add a join clause to the query.
- *
- * @param string $table
- * @param string $one
- * @param string $operator
- * @param string $two
- * @param string $type
- * @param bool $where
- * @return $this
- */
- public function join($table, $one, $operator = null, $two = null, $type = 'inner', $where = false)
- {
- // If the first "column" of the join is really a Closure instance the developer
- // is trying to build a join with a complex "on" clause containing more than
- // one condition, so we'll add the join and call a Closure with the query.
- if ($one instanceof Closure)
- {
- $this->joins[] = new JoinClause($type, $table);
-
- call_user_func($one, end($this->joins));
- }
-
- // If the column is simply a string, we can assume the join simply has a basic
- // "on" clause with a single condition. So we will just build the join with
- // this simple join clauses attached to it. There is not a join callback.
- else
- {
- $join = new JoinClause($type, $table);
-
- $this->joins[] = $join->on(
- $one, $operator, $two, 'and', $where
- );
- }
-
- return $this;
- }
-
- /**
- * Add a "join where" clause to the query.
- *
- * @param string $table
- * @param string $one
- * @param string $operator
- * @param string $two
- * @param string $type
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function joinWhere($table, $one, $operator, $two, $type = 'inner')
- {
- return $this->join($table, $one, $operator, $two, $type, true);
- }
-
- /**
- * Add a left join to the query.
- *
- * @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function leftJoin($table, $first, $operator = null, $second = null)
- {
- return $this->join($table, $first, $operator, $second, 'left');
- }
-
- /**
- * Add a "join where" clause to the query.
- *
- * @param string $table
- * @param string $one
- * @param string $operator
- * @param string $two
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function leftJoinWhere($table, $one, $operator, $two)
- {
- return $this->joinWhere($table, $one, $operator, $two, 'left');
- }
-
- /**
- * Add a right join to the query.
- *
- * @param string $table
- * @param string $first
- * @param string $operator
- * @param string $second
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function rightJoin($table, $first, $operator = null, $second = null)
- {
- return $this->join($table, $first, $operator, $second, 'right');
- }
-
- /**
- * Add a "right join where" clause to the query.
- *
- * @param string $table
- * @param string $one
- * @param string $operator
- * @param string $two
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function rightJoinWhere($table, $one, $operator, $two)
- {
- return $this->joinWhere($table, $one, $operator, $two, 'right');
- }
-
- /**
- * Add a basic where clause to the query.
- *
- * @param string $column
- * @param string $operator
- * @param mixed $value
- * @param string $boolean
- * @return $this
- *
- * @throws \InvalidArgumentException
- */
- public function where($column, $operator = null, $value = null, $boolean = 'and')
- {
- // If the column is an array, we will assume it is an array of key-value pairs
- // and can add them each as a where clause. We will maintain the boolean we
- // received when the method was called and pass it into the nested where.
- if (is_array($column))
- {
- return $this->whereNested(function($query) use ($column)
- {
- foreach ($column as $key => $value)
- {
- $query->where($key, '=', $value);
- }
- }, $boolean);
- }
-
- // Here we will make some assumptions about the operator. If only 2 values are
- // passed to the method, we will assume that the operator is an equals sign
- // and keep going. Otherwise, we'll require the operator to be passed in.
- if (func_num_args() == 2)
- {
- list($value, $operator) = array($operator, '=');
- }
- elseif ($this->invalidOperatorAndValue($operator, $value))
- {
- throw new \InvalidArgumentException("Value must be provided.");
- }
-
- // If the columns is actually a Closure instance, we will assume the developer
- // wants to begin a nested where statement which is wrapped in parenthesis.
- // We'll add that Closure to the query then return back out immediately.
- if ($column instanceof Closure)
- {
- return $this->whereNested($column, $boolean);
- }
-
- // If the given operator is not found in the list of valid operators we will
- // assume that the developer is just short-cutting the '=' operators and
- // we will set the operators to '=' and set the values appropriately.
- if ( ! in_array(strtolower($operator), $this->operators, true))
- {
- list($value, $operator) = array($operator, '=');
- }
-
- // If the value is a Closure, it means the developer is performing an entire
- // sub-select within the query and we will need to compile the sub-select
- // within the where clause to get the appropriate query record results.
- if ($value instanceof Closure)
- {
- return $this->whereSub($column, $operator, $value, $boolean);
- }
-
- // If the value is "null", we will just assume the developer wants to add a
- // where null clause to the query. So, we will allow a short-cut here to
- // that method for convenience so the developer doesn't have to check.
- if (is_null($value))
- {
- return $this->whereNull($column, $boolean, $operator != '=');
- }
-
- // Now that we are working with just a simple query we can put the elements
- // in our array and add the query binding to our array of bindings that
- // will be bound to each SQL statements when it is finally executed.
- $type = 'Basic';
-
- $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');
-
- if ( ! $value instanceof Expression)
- {
- $this->addBinding($value, 'where');
- }
-
- return $this;
- }
-
- /**
- * Add an "or where" clause to the query.
- *
- * @param string $column
- * @param string $operator
- * @param mixed $value
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhere($column, $operator = null, $value = null)
- {
- return $this->where($column, $operator, $value, 'or');
- }
-
- /**
- * Determine if the given operator and value combination is legal.
- *
- * @param string $operator
- * @param mixed $value
- * @return bool
- */
- protected function invalidOperatorAndValue($operator, $value)
- {
- $isOperator = in_array($operator, $this->operators);
-
- return ($isOperator && $operator != '=' && is_null($value));
- }
-
- /**
- * Add a raw where clause to the query.
- *
- * @param string $sql
- * @param array $bindings
- * @param string $boolean
- * @return $this
- */
- public function whereRaw($sql, array $bindings = array(), $boolean = 'and')
- {
- $type = 'raw';
-
- $this->wheres[] = compact('type', 'sql', 'boolean');
-
- $this->addBinding($bindings, 'where');
-
- return $this;
- }
-
- /**
- * Add a raw or where clause to the query.
- *
- * @param string $sql
- * @param array $bindings
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereRaw($sql, array $bindings = array())
- {
- return $this->whereRaw($sql, $bindings, 'or');
- }
-
- /**
- * Add a where between statement to the query.
- *
- * @param string $column
- * @param array $values
- * @param string $boolean
- * @param bool $not
- * @return $this
- */
- public function whereBetween($column, array $values, $boolean = 'and', $not = false)
- {
- $type = 'between';
-
- $this->wheres[] = compact('column', 'type', 'boolean', 'not');
-
- $this->addBinding($values, 'where');
-
- return $this;
- }
-
- /**
- * Add an or where between statement to the query.
- *
- * @param string $column
- * @param array $values
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereBetween($column, array $values)
- {
- return $this->whereBetween($column, $values, 'or');
- }
-
- /**
- * Add a where not between statement to the query.
- *
- * @param string $column
- * @param array $values
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereNotBetween($column, array $values, $boolean = 'and')
- {
- return $this->whereBetween($column, $values, $boolean, true);
- }
-
- /**
- * Add an or where not between statement to the query.
- *
- * @param string $column
- * @param array $values
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereNotBetween($column, array $values)
- {
- return $this->whereNotBetween($column, $values, 'or');
- }
-
- /**
- * Add a nested where statement to the query.
- *
- * @param \Closure $callback
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereNested(Closure $callback, $boolean = 'and')
- {
- // To handle nested queries we'll actually create a brand new query instance
- // and pass it off to the Closure that we have. The Closure can simply do
- // do whatever it wants to a query then we will store it for compiling.
- $query = $this->newQuery();
-
- $query->from($this->from);
-
- call_user_func($callback, $query);
-
- return $this->addNestedWhereQuery($query, $boolean);
- }
-
- /**
- * Add another query builder as a nested where to the query builder.
- *
- * @param \Illuminate\Database\Query\Builder|static $query
- * @param string $boolean
- * @return $this
- */
- public function addNestedWhereQuery($query, $boolean = 'and')
- {
- if (count($query->wheres))
- {
- $type = 'Nested';
-
- $this->wheres[] = compact('type', 'query', 'boolean');
-
- $this->mergeBindings($query);
- }
-
- return $this;
- }
-
- /**
- * Add a full sub-select to the query.
- *
- * @param string $column
- * @param string $operator
- * @param \Closure $callback
- * @param string $boolean
- * @return $this
- */
- protected function whereSub($column, $operator, Closure $callback, $boolean)
- {
- $type = 'Sub';
-
- $query = $this->newQuery();
-
- // Once we have the query instance we can simply execute it so it can add all
- // of the sub-select's conditions to itself, and then we can cache it off
- // in the array of where clauses for the "main" parent query instance.
- call_user_func($callback, $query);
-
- $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean');
-
- $this->mergeBindings($query);
-
- return $this;
- }
-
- /**
- * Add an exists clause to the query.
- *
- * @param \Closure $callback
- * @param string $boolean
- * @param bool $not
- * @return $this
- */
- public function whereExists(Closure $callback, $boolean = 'and', $not = false)
- {
- $type = $not ? 'NotExists' : 'Exists';
-
- $query = $this->newQuery();
-
- // Similar to the sub-select clause, we will create a new query instance so
- // the developer may cleanly specify the entire exists query and we will
- // compile the whole thing in the grammar and insert it into the SQL.
- call_user_func($callback, $query);
-
- $this->wheres[] = compact('type', 'operator', 'query', 'boolean');
-
- $this->mergeBindings($query);
-
- return $this;
- }
-
- /**
- * Add an or exists clause to the query.
- *
- * @param \Closure $callback
- * @param bool $not
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereExists(Closure $callback, $not = false)
- {
- return $this->whereExists($callback, 'or', $not);
- }
-
- /**
- * Add a where not exists clause to the query.
- *
- * @param \Closure $callback
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereNotExists(Closure $callback, $boolean = 'and')
- {
- return $this->whereExists($callback, $boolean, true);
- }
-
- /**
- * Add a where not exists clause to the query.
- *
- * @param \Closure $callback
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereNotExists(Closure $callback)
- {
- return $this->orWhereExists($callback, true);
- }
-
- /**
- * Add a "where in" clause to the query.
- *
- * @param string $column
- * @param mixed $values
- * @param string $boolean
- * @param bool $not
- * @return $this
- */
- public function whereIn($column, $values, $boolean = 'and', $not = false)
- {
- $type = $not ? 'NotIn' : 'In';
-
- // If the value of the where in clause is actually a Closure, we will assume that
- // the developer is using a full sub-select for this "in" statement, and will
- // execute those Closures, then we can re-construct the entire sub-selects.
- if ($values instanceof Closure)
- {
- return $this->whereInSub($column, $values, $boolean, $not);
- }
-
- $this->wheres[] = compact('type', 'column', 'values', 'boolean');
-
- $this->addBinding($values, 'where');
-
- return $this;
- }
-
- /**
- * Add an "or where in" clause to the query.
- *
- * @param string $column
- * @param mixed $values
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereIn($column, $values)
- {
- return $this->whereIn($column, $values, 'or');
- }
-
- /**
- * Add a "where not in" clause to the query.
- *
- * @param string $column
- * @param mixed $values
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereNotIn($column, $values, $boolean = 'and')
- {
- return $this->whereIn($column, $values, $boolean, true);
- }
-
- /**
- * Add an "or where not in" clause to the query.
- *
- * @param string $column
- * @param mixed $values
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereNotIn($column, $values)
- {
- return $this->whereNotIn($column, $values, 'or');
- }
-
- /**
- * Add a where in with a sub-select to the query.
- *
- * @param string $column
- * @param \Closure $callback
- * @param string $boolean
- * @param bool $not
- * @return $this
- */
- protected function whereInSub($column, Closure $callback, $boolean, $not)
- {
- $type = $not ? 'NotInSub' : 'InSub';
-
- // To create the exists sub-select, we will actually create a query and call the
- // provided callback with the query so the developer may set any of the query
- // conditions they want for the in clause, then we'll put it in this array.
- call_user_func($callback, $query = $this->newQuery());
-
- $this->wheres[] = compact('type', 'column', 'query', 'boolean');
-
- $this->mergeBindings($query);
-
- return $this;
- }
-
- /**
- * Add a "where null" clause to the query.
- *
- * @param string $column
- * @param string $boolean
- * @param bool $not
- * @return $this
- */
- public function whereNull($column, $boolean = 'and', $not = false)
- {
- $type = $not ? 'NotNull' : 'Null';
-
- $this->wheres[] = compact('type', 'column', 'boolean');
-
- return $this;
- }
-
- /**
- * Add an "or where null" clause to the query.
- *
- * @param string $column
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereNull($column)
- {
- return $this->whereNull($column, 'or');
- }
-
- /**
- * Add a "where not null" clause to the query.
- *
- * @param string $column
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereNotNull($column, $boolean = 'and')
- {
- return $this->whereNull($column, $boolean, true);
- }
-
- /**
- * Add an "or where not null" clause to the query.
- *
- * @param string $column
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orWhereNotNull($column)
- {
- return $this->whereNotNull($column, 'or');
- }
-
- /**
- * Add a "where date" statement to the query.
- *
- * @param string $column
- * @param string $operator
- * @param int $value
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereDate($column, $operator, $value, $boolean = 'and')
- {
- return $this->addDateBasedWhere('Date', $column, $operator, $value, $boolean);
- }
-
- /**
- * Add a "where day" statement to the query.
- *
- * @param string $column
- * @param string $operator
- * @param int $value
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereDay($column, $operator, $value, $boolean = 'and')
- {
- return $this->addDateBasedWhere('Day', $column, $operator, $value, $boolean);
- }
-
- /**
- * Add a "where month" statement to the query.
- *
- * @param string $column
- * @param string $operator
- * @param int $value
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereMonth($column, $operator, $value, $boolean = 'and')
- {
- return $this->addDateBasedWhere('Month', $column, $operator, $value, $boolean);
- }
-
- /**
- * Add a "where year" statement to the query.
- *
- * @param string $column
- * @param string $operator
- * @param int $value
- * @param string $boolean
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function whereYear($column, $operator, $value, $boolean = 'and')
- {
- return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean);
- }
-
- /**
- * Add a date based (year, month, day) statement to the query.
- *
- * @param string $type
- * @param string $column
- * @param string $operator
- * @param int $value
- * @param string $boolean
- * @return $this
- */
- protected function addDateBasedWhere($type, $column, $operator, $value, $boolean = 'and')
- {
- $this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value');
-
- $this->addBinding($value, 'where');
-
- return $this;
- }
-
- /**
- * Handles dynamic "where" clauses to the query.
- *
- * @param string $method
- * @param string $parameters
- * @return $this
- */
- public function dynamicWhere($method, $parameters)
- {
- $finder = substr($method, 5);
-
- $segments = preg_split('/(And|Or)(?=[A-Z])/', $finder, -1, PREG_SPLIT_DELIM_CAPTURE);
-
- // The connector variable will determine which connector will be used for the
- // query condition. We will change it as we come across new boolean values
- // in the dynamic method strings, which could contain a number of these.
- $connector = 'and';
-
- $index = 0;
-
- foreach ($segments as $segment)
- {
- // If the segment is not a boolean connector, we can assume it is a column's name
- // and we will add it to the query as a new constraint as a where clause, then
- // we can keep iterating through the dynamic method string's segments again.
- if ($segment != 'And' && $segment != 'Or')
- {
- $this->addDynamic($segment, $connector, $parameters, $index);
-
- $index++;
- }
-
- // Otherwise, we will store the connector so we know how the next where clause we
- // find in the query should be connected to the previous ones, meaning we will
- // have the proper boolean connector to connect the next where clause found.
- else
- {
- $connector = $segment;
- }
- }
-
- return $this;
- }
-
- /**
- * Add a single dynamic where clause statement to the query.
- *
- * @param string $segment
- * @param string $connector
- * @param array $parameters
- * @param int $index
- * @return void
- */
- protected function addDynamic($segment, $connector, $parameters, $index)
- {
- // Once we have parsed out the columns and formatted the boolean operators we
- // are ready to add it to this query as a where clause just like any other
- // clause on the query. Then we'll increment the parameter index values.
- $bool = strtolower($connector);
-
- $this->where(snake_case($segment), '=', $parameters[$index], $bool);
- }
-
- /**
- * Add a "group by" clause to the query.
- *
- * @param array|string $column,...
- * @return $this
- */
- public function groupBy()
- {
- foreach (func_get_args() as $arg)
- {
- $this->groups = array_merge((array) $this->groups, is_array($arg) ? $arg : [$arg]);
- }
-
- return $this;
- }
-
- /**
- * Add a "having" clause to the query.
- *
- * @param string $column
- * @param string $operator
- * @param string $value
- * @param string $boolean
- * @return $this
- */
- public function having($column, $operator = null, $value = null, $boolean = 'and')
- {
- $type = 'basic';
-
- $this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');
-
- $this->addBinding($value, 'having');
-
- return $this;
- }
-
- /**
- * Add a "or having" clause to the query.
- *
- * @param string $column
- * @param string $operator
- * @param string $value
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orHaving($column, $operator = null, $value = null)
- {
- return $this->having($column, $operator, $value, 'or');
- }
-
- /**
- * Add a raw having clause to the query.
- *
- * @param string $sql
- * @param array $bindings
- * @param string $boolean
- * @return $this
- */
- public function havingRaw($sql, array $bindings = array(), $boolean = 'and')
- {
- $type = 'raw';
-
- $this->havings[] = compact('type', 'sql', 'boolean');
-
- $this->addBinding($bindings, 'having');
-
- return $this;
- }
-
- /**
- * Add a raw or having clause to the query.
- *
- * @param string $sql
- * @param array $bindings
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function orHavingRaw($sql, array $bindings = array())
- {
- return $this->havingRaw($sql, $bindings, 'or');
- }
-
- /**
- * Add an "order by" clause to the query.
- *
- * @param string $column
- * @param string $direction
- * @return $this
- */
- public function orderBy($column, $direction = 'asc')
- {
- $property = $this->unions ? 'unionOrders' : 'orders';
- $direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';
-
- $this->{$property}[] = compact('column', 'direction');
-
- return $this;
- }
-
- /**
- * Add an "order by" clause for a timestamp to the query.
- *
- * @param string $column
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function latest($column = 'created_at')
- {
- return $this->orderBy($column, 'desc');
- }
-
- /**
- * Add an "order by" clause for a timestamp to the query.
- *
- * @param string $column
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function oldest($column = 'created_at')
- {
- return $this->orderBy($column, 'asc');
- }
-
- /**
- * Add a raw "order by" clause to the query.
- *
- * @param string $sql
- * @param array $bindings
- * @return $this
- */
- public function orderByRaw($sql, $bindings = array())
- {
- $type = 'raw';
-
- $this->orders[] = compact('type', 'sql');
-
- $this->addBinding($bindings, 'order');
-
- return $this;
- }
-
- /**
- * Set the "offset" value of the query.
- *
- * @param int $value
- * @return $this
- */
- public function offset($value)
- {
- $property = $this->unions ? 'unionOffset' : 'offset';
-
- $this->$property = max(0, $value);
-
- return $this;
- }
-
- /**
- * Alias to set the "offset" value of the query.
- *
- * @param int $value
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function skip($value)
- {
- return $this->offset($value);
- }
-
- /**
- * Set the "limit" value of the query.
- *
- * @param int $value
- * @return $this
- */
- public function limit($value)
- {
- $property = $this->unions ? 'unionLimit' : 'limit';
-
- if ($value > 0) $this->$property = $value;
-
- return $this;
- }
-
- /**
- * Alias to set the "limit" value of the query.
- *
- * @param int $value
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function take($value)
- {
- return $this->limit($value);
- }
-
- /**
- * Set the limit and offset for a given page.
- *
- * @param int $page
- * @param int $perPage
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function forPage($page, $perPage = 15)
- {
- return $this->skip(($page - 1) * $perPage)->take($perPage);
- }
-
- /**
- * Add a union statement to the query.
- *
- * @param \Illuminate\Database\Query\Builder|\Closure $query
- * @param bool $all
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function union($query, $all = false)
- {
- if ($query instanceof Closure)
- {
- call_user_func($query, $query = $this->newQuery());
- }
-
- $this->unions[] = compact('query', 'all');
-
- return $this->mergeBindings($query);
- }
-
- /**
- * Add a union all statement to the query.
- *
- * @param \Illuminate\Database\Query\Builder|\Closure $query
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function unionAll($query)
- {
- return $this->union($query, true);
- }
-
- /**
- * Lock the selected rows in the table.
- *
- * @param bool $value
- * @return $this
- */
- public function lock($value = true)
- {
- $this->lock = $value;
-
- return $this;
- }
-
- /**
- * Lock the selected rows in the table for updating.
- *
- * @return \Illuminate\Database\Query\Builder
- */
- public function lockForUpdate()
- {
- return $this->lock(true);
- }
-
- /**
- * Share lock the selected rows in the table.
- *
- * @return \Illuminate\Database\Query\Builder
- */
- public function sharedLock()
- {
- return $this->lock(false);
- }
-
- /**
- * Get the SQL representation of the query.
- *
- * @return string
- */
- public function toSql()
- {
- return $this->grammar->compileSelect($this);
- }
-
- /**
- * Indicate that the query results should be cached.
- *
- * @param \DateTime|int $minutes
- * @param string $key
- * @return $this
- */
- public function remember($minutes, $key = null)
- {
- list($this->cacheMinutes, $this->cacheKey) = array($minutes, $key);
-
- return $this;
- }
-
- /**
- * Indicate that the query results should be cached forever.
- *
- * @param string $key
- * @return \Illuminate\Database\Query\Builder|static
- */
- public function rememberForever($key = null)
- {
- return $this->remember(-1, $key);
- }
-
- /**
- * Indicate that the results, if cached, should use the given cache tags.
- *
- * @param array|mixed $cacheTags
- * @return $this
- */
- public function cacheTags($cacheTags)
- {
- $this->cacheTags = $cacheTags;
-
- return $this;
- }
-
- /**
- * Indicate that the results, if cached, should use the given cache driver.
- *
- * @param string $cacheDriver
- * @return $this
- */
- public function cacheDriver($cacheDriver)
- {
- $this->cacheDriver = $cacheDriver;
-
- return $this;
- }
-
- /**
- * Execute a query for a single record by ID.
- *
- * @param int $id
- * @param array $columns
- * @return mixed|static
- */
- public function find($id, $columns = array('*'))
- {
- return $this->where('id', '=', $id)->first($columns);
- }
-
- /**
- * Pluck a single column's value from the first result of a query.
- *
- * @param string $column
- * @return mixed
- */
- public function pluck($column)
- {
- $result = (array) $this->first(array($column));
-
- return count($result) > 0 ? reset($result) : null;
- }
-
- /**
- * Execute the query and get the first result.
- *
- * @param array $columns
- * @return mixed|static
- */
- public function first($columns = array('*'))
- {
- $results = $this->take(1)->get($columns);
-
- return count($results) > 0 ? reset($results) : null;
- }
-
- /**
- * Execute the query as a "select" statement.
- *
- * @param array $columns
- * @return array|static[]
- */
- public function get($columns = array('*'))
- {
- if ( ! is_null($this->cacheMinutes)) return $this->getCached($columns);
-
- return $this->getFresh($columns);
- }
-
- /**
- * Execute the query as a fresh "select" statement.
- *
- * @param array $columns
- * @return array|static[]
- */
- public function getFresh($columns = array('*'))
- {
- if (is_null($this->columns)) $this->columns = $columns;
-
- return $this->processor->processSelect($this, $this->runSelect());
- }
-
- /**
- * Run the query as a "select" statement against the connection.
- *
- * @return array
- */
- protected function runSelect()
- {
- if ($this->useWritePdo)
- {
- return $this->connection->select($this->toSql(), $this->getBindings(), false);
- }
-
- return $this->connection->select($this->toSql(), $this->getBindings());
- }
-
- /**
- * Execute the query as a cached "select" statement.
- *
- * @param array $columns
- * @return array
- */
- public function getCached($columns = array('*'))
- {
- if (is_null($this->columns)) $this->columns = $columns;
-
- // If the query is requested to be cached, we will cache it using a unique key
- // for this database connection and query statement, including the bindings
- // that are used on this query, providing great convenience when caching.
- list($key, $minutes) = $this->getCacheInfo();
-
- $cache = $this->getCache();
-
- $callback = $this->getCacheCallback($columns);
-
- // If the "minutes" value is less than zero, we will use that as the indicator
- // that the value should be remembered values should be stored indefinitely
- // and if we have minutes we will use the typical remember function here.
- if ($minutes < 0)
- {
- return $cache->rememberForever($key, $callback);
- }
-
- return $cache->remember($key, $minutes, $callback);
- }
-
- /**
- * Get the cache object with tags assigned, if applicable.
- *
- * @return \Illuminate\Cache\CacheManager
- */
- protected function getCache()
- {
- $cache = $this->connection->getCacheManager()->driver($this->cacheDriver);
-
- return $this->cacheTags ? $cache->tags($this->cacheTags) : $cache;
- }
-
- /**
- * Get the cache key and cache minutes as an array.
- *
- * @return array
- */
- protected function getCacheInfo()
- {
- return array($this->getCacheKey(), $this->cacheMinutes);
- }
-
- /**
- * Get a unique cache key for the complete query.
- *
- * @return string
- */
- public function getCacheKey()
- {
- return $this->cacheKey ?: $this->generateCacheKey();
- }
-
- /**
- * Generate the unique cache key for the query.
- *
- * @return string
- */
- public function generateCacheKey()
- {
- $name = $this->connection->getName();
-
- return md5($name.$this->toSql().serialize($this->getBindings()));
- }
-
- /**
- * Get the Closure callback used when caching queries.
- *
- * @param array $columns
- * @return \Closure
- */
- protected function getCacheCallback($columns)
- {
- return function() use ($columns) { return $this->getFresh($columns); };
- }
-
- /**
- * Chunk the results of the query.
- *
- * @param int $count
- * @param callable $callback
- * @return void
- */
- public function chunk($count, callable $callback)
- {
- $results = $this->forPage($page = 1, $count)->get();
-
- while (count($results) > 0)
- {
- // On each chunk result set, we will pass them to the callback and then let the
- // developer take care of everything within the callback, which allows us to
- // keep the memory low for spinning through large result sets for working.
- call_user_func($callback, $results);
-
- $page++;
-
- $results = $this->forPage($page, $count)->get();
- }
- }
-
- /**
- * Get an array with the values of a given column.
- *
- * @param string $column
- * @param string $key
- * @return array
- */
- public function lists($column, $key = null)
- {
- $columns = $this->getListSelect($column, $key);
-
- // First we will just get all of the column values for the record result set
- // then we can associate those values with the column if it was specified
- // otherwise we can just give these values back without a specific key.
- $results = new Collection($this->get($columns));
-
- $values = $results->fetch($columns[0])->all();
-
- // If a key was specified and we have results, we will go ahead and combine
- // the values with the keys of all of the records so that the values can
- // be accessed by the key of the rows instead of simply being numeric.
- if ( ! is_null($key) && count($results) > 0)
- {
- $keys = $results->fetch($key)->all();
-
- return array_combine($keys, $values);
- }
-
- return $values;
- }
-
- /**
- * Get the columns that should be used in a list array.
- *
- * @param string $column
- * @param string $key
- * @return array
- */
- protected function getListSelect($column, $key)
- {
- $select = is_null($key) ? array($column) : array($column, $key);
-
- // If the selected column contains a "dot", we will remove it so that the list
- // operation can run normally. Specifying the table is not needed, since we
- // really want the names of the columns as it is in this resulting array.
- if (($dot = strpos($select[0], '.')) !== false)
- {
- $select[0] = substr($select[0], $dot + 1);
- }
-
- return $select;
- }
-
- /**
- * Concatenate values of a given column as a string.
- *
- * @param string $column
- * @param string $glue
- * @return string
- */
- public function implode($column, $glue = null)
- {
- if (is_null($glue)) return implode($this->lists($column));
-
- return implode($glue, $this->lists($column));
- }
-
- /**
- * Get a paginator for the "select" statement.
- *
- * @param int $perPage
- * @param array $columns
- * @return \Illuminate\Pagination\Paginator
- */
- public function paginate($perPage = 15, $columns = array('*'))
- {
- $paginator = $this->connection->getPaginator();
-
- if (isset($this->groups))
- {
- return $this->groupedPaginate($paginator, $perPage, $columns);
- }
-
- return $this->ungroupedPaginate($paginator, $perPage, $columns);
- }
-
- /**
- * Create a paginator for a grouped pagination statement.
- *
- * @param \Illuminate\Pagination\Factory $paginator
- * @param int $perPage
- * @param array $columns
- * @return \Illuminate\Pagination\Paginator
- */
- protected function groupedPaginate($paginator, $perPage, $columns)
- {
- $results = $this->get($columns);
-
- return $this->buildRawPaginator($paginator, $results, $perPage);
- }
-
- /**
- * Build a paginator instance from a raw result array.
- *
- * @param \Illuminate\Pagination\Factory $paginator
- * @param array $results
- * @param int $perPage
- * @return \Illuminate\Pagination\Paginator
- */
- public function buildRawPaginator($paginator, $results, $perPage)
- {
- // For queries which have a group by, we will actually retrieve the entire set
- // of rows from the table and "slice" them via PHP. This is inefficient and
- // the developer must be aware of this behavior; however, it's an option.
- $start = ($paginator->getCurrentPage() - 1) * $perPage;
-
- $sliced = array_slice($results, $start, $perPage);
-
- return $paginator->make($sliced, count($results), $perPage);
- }
-
- /**
- * Create a paginator for an un-grouped pagination statement.
- *
- * @param \Illuminate\Pagination\Factory $paginator
- * @param int $perPage
- * @param array $columns
- * @return \Illuminate\Pagination\Paginator
- */
- protected function ungroupedPaginate($paginator, $perPage, $columns)
- {
- $total = $this->getPaginationCount();
-
- // Once we have the total number of records to be paginated, we can grab the
- // current page and the result array. Then we are ready to create a brand
- // new Paginator instances for the results which will create the links.
- $page = $paginator->getCurrentPage($total);
-
- $results = $this->forPage($page, $perPage)->get($columns);
-
- return $paginator->make($results, $total, $perPage);
- }
-
- /**
- * Get the count of the total records for pagination.
- *
- * @return int
- */
- public function getPaginationCount()
- {
- $this->backupFieldsForCount();
-
- // Because some database engines may throw errors if we leave the ordering
- // statements on the query, we will "back them up" and remove them from
- // the query. Once we have the count we will put them back onto this.
- $total = $this->count();
-
- $this->restoreFieldsForCount();
-
- return $total;
- }
-
- /**
- * Get a paginator only supporting simple next and previous links.
- *
- * This is more efficient on larger data-sets, etc.
- *
- * @param int $perPage
- * @param array $columns
- * @return \Illuminate\Pagination\Paginator
- */
- public function simplePaginate($perPage = null, $columns = array('*'))
- {
- $paginator = $this->connection->getPaginator();
-
- $page = $paginator->getCurrentPage();
-
- $perPage = $perPage ?: $this->model->getPerPage();
-
- $this->skip(($page - 1) * $perPage)->take($perPage + 1);
-
- return $paginator->make($this->get($columns), $perPage);
- }
-
- /**
- * Backup certain fields for a pagination count.
- *
- * @return void
- */
- protected function backupFieldsForCount()
- {
- foreach (array('orders', 'limit', 'offset') as $field)
- {
- $this->backups[$field] = $this->{$field};
-
- $this->{$field} = null;
- }
-
- }
-
- /**
- * Restore certain fields for a pagination count.
- *
- * @return void
- */
- protected function restoreFieldsForCount()
- {
- foreach (array('orders', 'limit', 'offset') as $field)
- {
- $this->{$field} = $this->backups[$field];
- }
-
- $this->backups = array();
- }
-
- /**
- * Determine if any rows exist for the current query.
- *
- * @return bool
- */
- public function exists()
- {
- $limit = $this->limit;
-
- $result = $this->limit(1)->count() > 0;
-
- $this->limit($limit);
-
- return $result;
- }
-
- /**
- * Retrieve the "count" result of the query.
- *
- * @param string $columns
- * @return int
- */
- public function count($columns = '*')
- {
- if ( ! is_array($columns))
- {
- $columns = array($columns);
- }
-
- return (int) $this->aggregate(__FUNCTION__, $columns);
- }
-
- /**
- * Retrieve the minimum value of a given column.
- *
- * @param string $column
- * @return mixed
- */
- public function min($column)
- {
- return $this->aggregate(__FUNCTION__, array($column));
- }
-
- /**
- * Retrieve the maximum value of a given column.
- *
- * @param string $column
- * @return mixed
- */
- public function max($column)
- {
- return $this->aggregate(__FUNCTION__, array($column));
- }
-
- /**
- * Retrieve the sum of the values of a given column.
- *
- * @param string $column
- * @return mixed
- */
- public function sum($column)
- {
- $result = $this->aggregate(__FUNCTION__, array($column));
-
- return $result ?: 0;
- }
-
- /**
- * Retrieve the average of the values of a given column.
- *
- * @param string $column
- * @return mixed
- */
- public function avg($column)
- {
- return $this->aggregate(__FUNCTION__, array($column));
- }
-
- /**
- * Execute an aggregate function on the database.
- *
- * @param string $function
- * @param array $columns
- * @return mixed
- */
- public function aggregate($function, $columns = array('*'))
- {
- $this->aggregate = compact('function', 'columns');
-
- $previousColumns = $this->columns;
-
- $results = $this->get($columns);
-
- // Once we have executed the query, we will reset the aggregate property so
- // that more select queries can be executed against the database without
- // the aggregate value getting in the way when the grammar builds it.
- $this->aggregate = null;
-
- $this->columns = $previousColumns;
-
- if (isset($results[0]))
- {
- $result = array_change_key_case((array) $results[0]);
-
- return $result['aggregate'];
- }
- }
-
- /**
- * Insert a new record into the database.
- *
- * @param array $values
- * @return bool
- */
- public function insert(array $values)
- {
- // Since every insert gets treated like a batch insert, we will make sure the
- // bindings are structured in a way that is convenient for building these
- // inserts statements by verifying the elements are actually an array.
- if ( ! is_array(reset($values)))
- {
- $values = array($values);
- }
-
- // Since every insert gets treated like a batch insert, we will make sure the
- // bindings are structured in a way that is convenient for building these
- // inserts statements by verifying the elements are actually an array.
- else
- {
- foreach ($values as $key => $value)
- {
- ksort($value); $values[$key] = $value;
- }
- }
-
- // We'll treat every insert like a batch insert so we can easily insert each
- // of the records into the database consistently. This will make it much
- // easier on the grammars to just handle one type of record insertion.
- $bindings = array();
-
- foreach ($values as $record)
- {
- foreach ($record as $value)
- {
- $bindings[] = $value;
- }
- }
-
- $sql = $this->grammar->compileInsert($this, $values);
-
- // Once we have compiled the insert statement's SQL we can execute it on the
- // connection and return a result as a boolean success indicator as that
- // is the same type of result returned by the raw connection instance.
- $bindings = $this->cleanBindings($bindings);
-
- return $this->connection->insert($sql, $bindings);
- }
-
- /**
- * Insert a new record and get the value of the primary key.
- *
- * @param array $values
- * @param string $sequence
- * @return int
- */
- public function insertGetId(array $values, $sequence = null)
- {
- $sql = $this->grammar->compileInsertGetId($this, $values, $sequence);
-
- $values = $this->cleanBindings($values);
-
- return $this->processor->processInsertGetId($this, $sql, $values, $sequence);
- }
-
- /**
- * Update a record in the database.
- *
- * @param array $values
- * @return int
- */
- public function update(array $values)
- {
- $bindings = array_values(array_merge($values, $this->getBindings()));
-
- $sql = $this->grammar->compileUpdate($this, $values);
-
- return $this->connection->update($sql, $this->cleanBindings($bindings));
- }
-
- /**
- * Increment a column's value by a given amount.
- *
- * @param string $column
- * @param int $amount
- * @param array $extra
- * @return int
- */
- public function increment($column, $amount = 1, array $extra = array())
- {
- $wrapped = $this->grammar->wrap($column);
-
- $columns = array_merge(array($column => $this->raw("$wrapped + $amount")), $extra);
-
- return $this->update($columns);
- }
-
- /**
- * Decrement a column's value by a given amount.
- *
- * @param string $column
- * @param int $amount
- * @param array $extra
- * @return int
- */
- public function decrement($column, $amount = 1, array $extra = array())
- {
- $wrapped = $this->grammar->wrap($column);
-
- $columns = array_merge(array($column => $this->raw("$wrapped - $amount")), $extra);
-
- return $this->update($columns);
- }
-
- /**
- * Delete a record from the database.
- *
- * @param mixed $id
- * @return int
- */
- public function delete($id = null)
- {
- // If an ID is passed to the method, we will set the where clause to check
- // the ID to allow developers to simply and quickly remove a single row
- // from their database without manually specifying the where clauses.
- if ( ! is_null($id)) $this->where('id', '=', $id);
-
- $sql = $this->grammar->compileDelete($this);
-
- return $this->connection->delete($sql, $this->getBindings());
- }
-
- /**
- * Run a truncate statement on the table.
- *
- * @return void
- */
- public function truncate()
- {
- foreach ($this->grammar->compileTruncate($this) as $sql => $bindings)
- {
- $this->connection->statement($sql, $bindings);
- }
- }
-
- /**
- * Get a new instance of the query builder.
- *
- * @return \Illuminate\Database\Query\Builder
- */
- public function newQuery()
- {
- return new Builder($this->connection, $this->grammar, $this->processor);
- }
-
- /**
- * Merge an array of where clauses and bindings.
- *
- * @param array $wheres
- * @param array $bindings
- * @return void
- */
- public function mergeWheres($wheres, $bindings)
- {
- $this->wheres = array_merge((array) $this->wheres, (array) $wheres);
-
- $this->bindings['where'] = array_values(array_merge($this->bindings['where'], (array) $bindings));
- }
-
- /**
- * Remove all of the expressions from a list of bindings.
- *
- * @param array $bindings
- * @return array
- */
- protected function cleanBindings(array $bindings)
- {
- return array_values(array_filter($bindings, function($binding)
- {
- return ! $binding instanceof Expression;
- }));
- }
-
- /**
- * Create a raw database expression.
- *
- * @param mixed $value
- * @return \Illuminate\Database\Query\Expression
- */
- public function raw($value)
- {
- return $this->connection->raw($value);
- }
-
- /**
- * Get the current query value bindings in a flattened array.
- *
- * @return array
- */
- public function getBindings()
- {
- return array_flatten($this->bindings);
- }
-
- /**
- * Get the raw array of bindings.
- *
- * @return array
- */
- public function getRawBindings()
- {
- return $this->bindings;
- }
-
- /**
- * Set the bindings on the query builder.
- *
- * @param array $bindings
- * @param string $type
- * @return $this
- *
- * @throws \InvalidArgumentException
- */
- public function setBindings(array $bindings, $type = 'where')
- {
- if ( ! array_key_exists($type, $this->bindings))
- {
- throw new \InvalidArgumentException("Invalid binding type: {$type}.");
- }
-
- $this->bindings[$type] = $bindings;
-
- return $this;
- }
-
- /**
- * Add a binding to the query.
- *
- * @param mixed $value
- * @param string $type
- * @return $this
- *
- * @throws \InvalidArgumentException
- */
- public function addBinding($value, $type = 'where')
- {
- if ( ! array_key_exists($type, $this->bindings))
- {
- throw new \InvalidArgumentException("Invalid binding type: {$type}.");
- }
-
- if (is_array($value))
- {
- $this->bindings[$type] = array_values(array_merge($this->bindings[$type], $value));
- }
- else
- {
- $this->bindings[$type][] = $value;
- }
-
- return $this;
- }
-
- /**
- * Merge an array of bindings into our bindings.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return $this
- */
- public function mergeBindings(Builder $query)
- {
- $this->bindings = array_merge_recursive($this->bindings, $query->bindings);
-
- return $this;
- }
-
- /**
- * Get the database connection instance.
- *
- * @return \Illuminate\Database\ConnectionInterface
- */
- public function getConnection()
- {
- return $this->connection;
- }
-
- /**
- * Get the database query processor instance.
- *
- * @return \Illuminate\Database\Query\Processors\Processor
- */
- public function getProcessor()
- {
- return $this->processor;
- }
-
- /**
- * Get the query grammar instance.
- *
- * @return \Illuminate\Database\Grammar
- */
- public function getGrammar()
- {
- return $this->grammar;
- }
-
- /**
- * Use the write pdo for query.
- *
- * @return $this
- */
- public function useWritePdo()
- {
- $this->useWritePdo = true;
-
- return $this;
- }
-
- /**
- * Handle dynamic method calls into the method.
- *
- * @param string $method
- * @param array $parameters
- * @return mixed
- *
- * @throws \BadMethodCallException
- */
- public function __call($method, $parameters)
- {
- if (starts_with($method, 'where'))
- {
- return $this->dynamicWhere($method, $parameters);
- }
-
- $className = get_class($this);
-
- throw new \BadMethodCallException("Call to undefined method {$className}::{$method}()");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php
deleted file mode 100755
index 68d2236..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php namespace Illuminate\Database\Query;
-
-class Expression {
-
- /**
- * The value of the expression.
- *
- * @var mixed
- */
- protected $value;
-
- /**
- * Create a new raw query expression.
- *
- * @param mixed $value
- * @return void
- */
- public function __construct($value)
- {
- $this->value = $value;
- }
-
- /**
- * Get the value of the expression.
- *
- * @return mixed
- */
- public function getValue()
- {
- return $this->value;
- }
-
- /**
- * Get the value of the expression.
- *
- * @return string
- */
- public function __toString()
- {
- return (string) $this->getValue();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
deleted file mode 100755
index 6998370..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
+++ /dev/null
@@ -1,759 +0,0 @@
-<?php namespace Illuminate\Database\Query\Grammars;
-
-use Illuminate\Database\Query\Builder;
-use Illuminate\Database\Grammar as BaseGrammar;
-
-class Grammar extends BaseGrammar {
-
- /**
- * The components that make up a select clause.
- *
- * @var array
- */
- protected $selectComponents = array(
- 'aggregate',
- 'columns',
- 'from',
- 'joins',
- 'wheres',
- 'groups',
- 'havings',
- 'orders',
- 'limit',
- 'offset',
- 'unions',
- 'lock',
- );
-
- /**
- * Compile a select query into SQL.
- *
- * @param \Illuminate\Database\Query\Builder
- * @return string
- */
- public function compileSelect(Builder $query)
- {
- if (is_null($query->columns)) $query->columns = array('*');
-
- return trim($this->concatenate($this->compileComponents($query)));
- }
-
- /**
- * Compile the components necessary for a select clause.
- *
- * @param \Illuminate\Database\Query\Builder
- * @return array
- */
- protected function compileComponents(Builder $query)
- {
- $sql = array();
-
- foreach ($this->selectComponents as $component)
- {
- // To compile the query, we'll spin through each component of the query and
- // see if that component exists. If it does we'll just call the compiler
- // function for the component which is responsible for making the SQL.
- if ( ! is_null($query->$component))
- {
- $method = 'compile'.ucfirst($component);
-
- $sql[$component] = $this->$method($query, $query->$component);
- }
- }
-
- return $sql;
- }
-
- /**
- * Compile an aggregated select clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $aggregate
- * @return string
- */
- protected function compileAggregate(Builder $query, $aggregate)
- {
- $column = $this->columnize($aggregate['columns']);
-
- // If the query has a "distinct" constraint and we're not asking for all columns
- // we need to prepend "distinct" onto the column name so that the query takes
- // it into account when it performs the aggregating operations on the data.
- if ($query->distinct && $column !== '*')
- {
- $column = 'distinct '.$column;
- }
-
- return 'select '.$aggregate['function'].'('.$column.') as aggregate';
- }
-
- /**
- * Compile the "select *" portion of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $columns
- * @return string
- */
- protected function compileColumns(Builder $query, $columns)
- {
- // If the query is actually performing an aggregating select, we will let that
- // compiler handle the building of the select clauses, as it will need some
- // more syntax that is best handled by that function to keep things neat.
- if ( ! is_null($query->aggregate)) return;
-
- $select = $query->distinct ? 'select distinct ' : 'select ';
-
- return $select.$this->columnize($columns);
- }
-
- /**
- * Compile the "from" portion of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param string $table
- * @return string
- */
- protected function compileFrom(Builder $query, $table)
- {
- return 'from '.$this->wrapTable($table);
- }
-
- /**
- * Compile the "join" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $joins
- * @return string
- */
- protected function compileJoins(Builder $query, $joins)
- {
- $sql = array();
-
- $query->setBindings(array(), 'join');
-
- foreach ($joins as $join)
- {
- $table = $this->wrapTable($join->table);
-
- // First we need to build all of the "on" clauses for the join. There may be many
- // of these clauses so we will need to iterate through each one and build them
- // separately, then we'll join them up into a single string when we're done.
- $clauses = array();
-
- foreach ($join->clauses as $clause)
- {
- $clauses[] = $this->compileJoinConstraint($clause);
- }
-
- foreach ($join->bindings as $binding)
- {
- $query->addBinding($binding, 'join');
- }
-
- // Once we have constructed the clauses, we'll need to take the boolean connector
- // off of the first clause as it obviously will not be required on that clause
- // because it leads the rest of the clauses, thus not requiring any boolean.
- $clauses[0] = $this->removeLeadingBoolean($clauses[0]);
-
- $clauses = implode(' ', $clauses);
-
- $type = $join->type;
-
- // Once we have everything ready to go, we will just concatenate all the parts to
- // build the final join statement SQL for the query and we can then return the
- // final clause back to the callers as a single, stringified join statement.
- $sql[] = "$type join $table on $clauses";
- }
-
- return implode(' ', $sql);
- }
-
- /**
- * Create a join clause constraint segment.
- *
- * @param array $clause
- * @return string
- */
- protected function compileJoinConstraint(array $clause)
- {
- $first = $this->wrap($clause['first']);
-
- $second = $clause['where'] ? '?' : $this->wrap($clause['second']);
-
- return "{$clause['boolean']} $first {$clause['operator']} $second";
- }
-
- /**
- * Compile the "where" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- protected function compileWheres(Builder $query)
- {
- $sql = array();
-
- if (is_null($query->wheres)) return '';
-
- // Each type of where clauses has its own compiler function which is responsible
- // for actually creating the where clauses SQL. This helps keep the code nice
- // and maintainable since each clause has a very small method that it uses.
- foreach ($query->wheres as $where)
- {
- $method = "where{$where['type']}";
-
- $sql[] = $where['boolean'].' '.$this->$method($query, $where);
- }
-
- // If we actually have some where clauses, we will strip off the first boolean
- // operator, which is added by the query builders for convenience so we can
- // avoid checking for the first clauses in each of the compilers methods.
- if (count($sql) > 0)
- {
- $sql = implode(' ', $sql);
-
- return 'where '.preg_replace('/and |or /', '', $sql, 1);
- }
-
- return '';
- }
-
- /**
- * Compile a nested where clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNested(Builder $query, $where)
- {
- $nested = $where['query'];
-
- return '('.substr($this->compileWheres($nested), 6).')';
- }
-
- /**
- * Compile a where condition with a sub-select.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereSub(Builder $query, $where)
- {
- $select = $this->compileSelect($where['query']);
-
- return $this->wrap($where['column']).' '.$where['operator']." ($select)";
- }
-
- /**
- * Compile a basic where clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereBasic(Builder $query, $where)
- {
- $value = $this->parameter($where['value']);
-
- return $this->wrap($where['column']).' '.$where['operator'].' '.$value;
- }
-
- /**
- * Compile a "between" where clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereBetween(Builder $query, $where)
- {
- $between = $where['not'] ? 'not between' : 'between';
-
- return $this->wrap($where['column']).' '.$between.' ? and ?';
- }
-
- /**
- * Compile a where exists clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereExists(Builder $query, $where)
- {
- return 'exists ('.$this->compileSelect($where['query']).')';
- }
-
- /**
- * Compile a where exists clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNotExists(Builder $query, $where)
- {
- return 'not exists ('.$this->compileSelect($where['query']).')';
- }
-
- /**
- * Compile a "where in" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereIn(Builder $query, $where)
- {
- if (empty($where['values'])) return '0 = 1';
-
- $values = $this->parameterize($where['values']);
-
- return $this->wrap($where['column']).' in ('.$values.')';
- }
-
- /**
- * Compile a "where not in" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNotIn(Builder $query, $where)
- {
- if (empty($where['values'])) return '1 = 1';
-
- $values = $this->parameterize($where['values']);
-
- return $this->wrap($where['column']).' not in ('.$values.')';
- }
-
- /**
- * Compile a where in sub-select clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereInSub(Builder $query, $where)
- {
- $select = $this->compileSelect($where['query']);
-
- return $this->wrap($where['column']).' in ('.$select.')';
- }
-
- /**
- * Compile a where not in sub-select clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNotInSub(Builder $query, $where)
- {
- $select = $this->compileSelect($where['query']);
-
- return $this->wrap($where['column']).' not in ('.$select.')';
- }
-
- /**
- * Compile a "where null" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNull(Builder $query, $where)
- {
- return $this->wrap($where['column']).' is null';
- }
-
- /**
- * Compile a "where not null" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereNotNull(Builder $query, $where)
- {
- return $this->wrap($where['column']).' is not null';
- }
-
- /**
- * Compile a "where date" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereDate(Builder $query, $where)
- {
- return $this->dateBasedWhere('date', $query, $where);
- }
-
- /**
- * Compile a "where day" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereDay(Builder $query, $where)
- {
- return $this->dateBasedWhere('day', $query, $where);
- }
-
- /**
- * Compile a "where month" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereMonth(Builder $query, $where)
- {
- return $this->dateBasedWhere('month', $query, $where);
- }
-
- /**
- * Compile a "where year" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereYear(Builder $query, $where)
- {
- return $this->dateBasedWhere('year', $query, $where);
- }
-
- /**
- * Compile a date based where clause.
- *
- * @param string $type
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function dateBasedWhere($type, Builder $query, $where)
- {
- $value = $this->parameter($where['value']);
-
- return $type.'('.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
- }
-
- /**
- * Compile a raw where clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereRaw(Builder $query, $where)
- {
- return $where['sql'];
- }
-
- /**
- * Compile the "group by" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $groups
- * @return string
- */
- protected function compileGroups(Builder $query, $groups)
- {
- return 'group by '.$this->columnize($groups);
- }
-
- /**
- * Compile the "having" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $havings
- * @return string
- */
- protected function compileHavings(Builder $query, $havings)
- {
- $sql = implode(' ', array_map(array($this, 'compileHaving'), $havings));
-
- return 'having '.preg_replace('/and |or /', '', $sql, 1);
- }
-
- /**
- * Compile a single having clause.
- *
- * @param array $having
- * @return string
- */
- protected function compileHaving(array $having)
- {
- // If the having clause is "raw", we can just return the clause straight away
- // without doing any more processing on it. Otherwise, we will compile the
- // clause into SQL based on the components that make it up from builder.
- if ($having['type'] === 'raw')
- {
- return $having['boolean'].' '.$having['sql'];
- }
-
- return $this->compileBasicHaving($having);
- }
-
- /**
- * Compile a basic having clause.
- *
- * @param array $having
- * @return string
- */
- protected function compileBasicHaving($having)
- {
- $column = $this->wrap($having['column']);
-
- $parameter = $this->parameter($having['value']);
-
- return $having['boolean'].' '.$column.' '.$having['operator'].' '.$parameter;
- }
-
- /**
- * Compile the "order by" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $orders
- * @return string
- */
- protected function compileOrders(Builder $query, $orders)
- {
- return 'order by '.implode(', ', array_map(function($order)
- {
- if (isset($order['sql'])) return $order['sql'];
-
- return $this->wrap($order['column']).' '.$order['direction'];
- }
- , $orders));
- }
-
- /**
- * Compile the "limit" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param int $limit
- * @return string
- */
- protected function compileLimit(Builder $query, $limit)
- {
- return 'limit '.(int) $limit;
- }
-
- /**
- * Compile the "offset" portions of the query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param int $offset
- * @return string
- */
- protected function compileOffset(Builder $query, $offset)
- {
- return 'offset '.(int) $offset;
- }
-
- /**
- * Compile the "union" queries attached to the main query.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- protected function compileUnions(Builder $query)
- {
- $sql = '';
-
- foreach ($query->unions as $union)
- {
- $sql .= $this->compileUnion($union);
- }
-
- if (isset($query->unionOrders))
- {
- $sql .= ' '.$this->compileOrders($query, $query->unionOrders);
- }
-
- if (isset($query->unionLimit))
- {
- $sql .= ' '.$this->compileLimit($query, $query->unionLimit);
- }
-
- if (isset($query->unionOffset))
- {
- $sql .= ' '.$this->compileOffset($query, $query->unionOffset);
- }
-
- return ltrim($sql);
- }
-
- /**
- * Compile a single union statement.
- *
- * @param array $union
- * @return string
- */
- protected function compileUnion(array $union)
- {
- $joiner = $union['all'] ? ' union all ' : ' union ';
-
- return $joiner.$union['query']->toSql();
- }
-
- /**
- * Compile an insert statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @return string
- */
- public function compileInsert(Builder $query, array $values)
- {
- // Essentially we will force every insert to be treated as a batch insert which
- // simply makes creating the SQL easier for us since we can utilize the same
- // basic routine regardless of an amount of records given to us to insert.
- $table = $this->wrapTable($query->from);
-
- if ( ! is_array(reset($values)))
- {
- $values = array($values);
- }
-
- $columns = $this->columnize(array_keys(reset($values)));
-
- // We need to build a list of parameter place-holders of values that are bound
- // to the query. Each insert should have the exact same amount of parameter
- // bindings so we can just go off the first list of values in this array.
- $parameters = $this->parameterize(reset($values));
-
- $value = array_fill(0, count($values), "($parameters)");
-
- $parameters = implode(', ', $value);
-
- return "insert into $table ($columns) values $parameters";
- }
-
- /**
- * Compile an insert and get ID statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @param string $sequence
- * @return string
- */
- public function compileInsertGetId(Builder $query, $values, $sequence)
- {
- return $this->compileInsert($query, $values);
- }
-
- /**
- * Compile an update statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @return string
- */
- public function compileUpdate(Builder $query, $values)
- {
- $table = $this->wrapTable($query->from);
-
- // Each one of the columns in the update statements needs to be wrapped in the
- // keyword identifiers, also a place-holder needs to be created for each of
- // the values in the list of bindings so we can make the sets statements.
- $columns = array();
-
- foreach ($values as $key => $value)
- {
- $columns[] = $this->wrap($key).' = '.$this->parameter($value);
- }
-
- $columns = implode(', ', $columns);
-
- // If the query has any "join" clauses, we will setup the joins on the builder
- // and compile them so we can attach them to this update, as update queries
- // can get join statements to attach to other tables when they're needed.
- if (isset($query->joins))
- {
- $joins = ' '.$this->compileJoins($query, $query->joins);
- }
- else
- {
- $joins = '';
- }
-
- // Of course, update queries may also be constrained by where clauses so we'll
- // need to compile the where clauses and attach it to the query so only the
- // intended records are updated by the SQL statements we generate to run.
- $where = $this->compileWheres($query);
-
- return trim("update {$table}{$joins} set $columns $where");
- }
-
- /**
- * Compile a delete statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- public function compileDelete(Builder $query)
- {
- $table = $this->wrapTable($query->from);
-
- $where = is_array($query->wheres) ? $this->compileWheres($query) : '';
-
- return trim("delete from $table ".$where);
- }
-
- /**
- * Compile a truncate table statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return array
- */
- public function compileTruncate(Builder $query)
- {
- return array('truncate '.$this->wrapTable($query->from) => array());
- }
-
- /**
- * Compile the lock into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param bool|string $value
- * @return string
- */
- protected function compileLock(Builder $query, $value)
- {
- return is_string($value) ? $value : '';
- }
-
- /**
- * Concatenate an array of segments, removing empties.
- *
- * @param array $segments
- * @return string
- */
- protected function concatenate($segments)
- {
- return implode(' ', array_filter($segments, function($value)
- {
- return (string) $value !== '';
- }));
- }
-
- /**
- * Remove the leading boolean from a statement.
- *
- * @param string $value
- * @return string
- */
- protected function removeLeadingBoolean($value)
- {
- return preg_replace('/and |or /', '', $value, 1);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
deleted file mode 100755
index b068e2b..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php namespace Illuminate\Database\Query\Grammars;
-
-use Illuminate\Database\Query\Builder;
-
-class MySqlGrammar extends Grammar {
-
- /**
- * The components that make up a select clause.
- *
- * @var array
- */
- protected $selectComponents = array(
- 'aggregate',
- 'columns',
- 'from',
- 'joins',
- 'wheres',
- 'groups',
- 'havings',
- 'orders',
- 'limit',
- 'offset',
- 'lock',
- );
-
- /**
- * Compile a select query into SQL.
- *
- * @param \Illuminate\Database\Query\Builder
- * @return string
- */
- public function compileSelect(Builder $query)
- {
- $sql = parent::compileSelect($query);
-
- if ($query->unions)
- {
- $sql = '('.$sql.') '.$this->compileUnions($query);
- }
-
- return $sql;
- }
-
- /**
- * Compile a single union statement.
- *
- * @param array $union
- * @return string
- */
- protected function compileUnion(array $union)
- {
- $joiner = $union['all'] ? ' union all ' : ' union ';
-
- return $joiner.'('.$union['query']->toSql().')';
- }
-
- /**
- * Compile the lock into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param bool|string $value
- * @return string
- */
- protected function compileLock(Builder $query, $value)
- {
- if (is_string($value)) return $value;
-
- return $value ? 'for update' : 'lock in share mode';
- }
-
- /**
- * Compile an update statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @return string
- */
- public function compileUpdate(Builder $query, $values)
- {
- $sql = parent::compileUpdate($query, $values);
-
- if (isset($query->orders))
- {
- $sql .= ' '.$this->compileOrders($query, $query->orders);
- }
-
- if (isset($query->limit))
- {
- $sql .= ' '.$this->compileLimit($query, $query->limit);
- }
-
- return rtrim($sql);
- }
-
- /**
- * Compile a delete statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- public function compileDelete(Builder $query)
- {
- $table = $this->wrapTable($query->from);
-
- $where = is_array($query->wheres) ? $this->compileWheres($query) : '';
-
- if (isset($query->joins))
- {
- $joins = ' '.$this->compileJoins($query, $query->joins);
-
- return trim("delete $table from {$table}{$joins} $where");
- }
-
- return trim("delete from $table $where");
- }
-
- /**
- * Wrap a single string in keyword identifiers.
- *
- * @param string $value
- * @return string
- */
- protected function wrapValue($value)
- {
- if ($value === '*') return $value;
-
- return '`'.str_replace('`', '``', $value).'`';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
deleted file mode 100755
index 7a8df9c..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php namespace Illuminate\Database\Query\Grammars;
-
-use Illuminate\Database\Query\Builder;
-
-class PostgresGrammar extends Grammar {
-
- /**
- * All of the available clause operators.
- *
- * @var array
- */
- protected $operators = array(
- '=', '<', '>', '<=', '>=', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
- '&', '|', '#', '<<', '>>',
- );
-
- /**
- * Compile the lock into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param bool|string $value
- * @return string
- */
- protected function compileLock(Builder $query, $value)
- {
- if (is_string($value)) return $value;
-
- return $value ? 'for update' : 'for share';
- }
-
- /**
- * Compile an update statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @return string
- */
- public function compileUpdate(Builder $query, $values)
- {
- $table = $this->wrapTable($query->from);
-
- // Each one of the columns in the update statements needs to be wrapped in the
- // keyword identifiers, also a place-holder needs to be created for each of
- // the values in the list of bindings so we can make the sets statements.
- $columns = $this->compileUpdateColumns($values);
-
- $from = $this->compileUpdateFrom($query);
-
- $where = $this->compileUpdateWheres($query);
-
- return trim("update {$table} set {$columns}{$from} $where");
- }
-
- /**
- * Compile the columns for the update statement.
- *
- * @param array $values
- * @return string
- */
- protected function compileUpdateColumns($values)
- {
- $columns = array();
-
- // When gathering the columns for an update statement, we'll wrap each of the
- // columns and convert it to a parameter value. Then we will concatenate a
- // list of the columns that can be added into this update query clauses.
- foreach ($values as $key => $value)
- {
- $columns[] = $this->wrap($key).' = '.$this->parameter($value);
- }
-
- return implode(', ', $columns);
- }
-
- /**
- * Compile the "from" clause for an update with a join.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- protected function compileUpdateFrom(Builder $query)
- {
- if ( ! isset($query->joins)) return '';
-
- $froms = array();
-
- // When using Postgres, updates with joins list the joined tables in the from
- // clause, which is different than other systems like MySQL. Here, we will
- // compile out the tables that are joined and add them to a from clause.
- foreach ($query->joins as $join)
- {
- $froms[] = $this->wrapTable($join->table);
- }
-
- if (count($froms) > 0) return ' from '.implode(', ', $froms);
- }
-
- /**
- * Compile the additional where clauses for updates with joins.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- protected function compileUpdateWheres(Builder $query)
- {
- $baseWhere = $this->compileWheres($query);
-
- if ( ! isset($query->joins)) return $baseWhere;
-
- // Once we compile the join constraints, we will either use them as the where
- // clause or append them to the existing base where clauses. If we need to
- // strip the leading boolean we will do so when using as the only where.
- $joinWhere = $this->compileUpdateJoinWheres($query);
-
- if (trim($baseWhere) == '')
- {
- return 'where '.$this->removeLeadingBoolean($joinWhere);
- }
-
- return $baseWhere.' '.$joinWhere;
- }
-
- /**
- * Compile the "join" clauses for an update.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return string
- */
- protected function compileUpdateJoinWheres(Builder $query)
- {
- $joinWheres = array();
-
- // Here we will just loop through all of the join constraints and compile them
- // all out then implode them. This should give us "where" like syntax after
- // everything has been built and then we will join it to the real wheres.
- foreach ($query->joins as $join)
- {
- foreach ($join->clauses as $clause)
- {
- $joinWheres[] = $this->compileJoinConstraint($clause);
- }
- }
-
- return implode(' ', $joinWheres);
- }
-
- /**
- * Compile an insert and get ID statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @param string $sequence
- * @return string
- */
- public function compileInsertGetId(Builder $query, $values, $sequence)
- {
- if (is_null($sequence)) $sequence = 'id';
-
- return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence);
- }
-
- /**
- * Compile a truncate table statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return array
- */
- public function compileTruncate(Builder $query)
- {
- return array('truncate '.$this->wrapTable($query->from).' restart identity' => array());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/80fd786e/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
----------------------------------------------------------------------
diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
deleted file mode 100755
index 01558d3..0000000
--- a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php namespace Illuminate\Database\Query\Grammars;
-
-use Illuminate\Database\Query\Builder;
-
-class SQLiteGrammar extends Grammar {
-
- /**
- * All of the available clause operators.
- *
- * @var array
- */
- protected $operators = array(
- '=', '<', '>', '<=', '>=', '<>', '!=',
- 'like', 'not like', 'between', 'ilike',
- '&', '|', '<<', '>>',
- );
-
- /**
- * Compile an insert statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $values
- * @return string
- */
- public function compileInsert(Builder $query, array $values)
- {
- // Essentially we will force every insert to be treated as a batch insert which
- // simply makes creating the SQL easier for us since we can utilize the same
- // basic routine regardless of an amount of records given to us to insert.
- $table = $this->wrapTable($query->from);
-
- if ( ! is_array(reset($values)))
- {
- $values = array($values);
- }
-
- // If there is only one record being inserted, we will just use the usual query
- // grammar insert builder because no special syntax is needed for the single
- // row inserts in SQLite. However, if there are multiples, we'll continue.
- if (count($values) == 1)
- {
- return parent::compileInsert($query, reset($values));
- }
-
- $names = $this->columnize(array_keys(reset($values)));
-
- $columns = array();
-
- // SQLite requires us to build the multi-row insert as a listing of select with
- // unions joining them together. So we'll build out this list of columns and
- // then join them all together with select unions to complete the queries.
- foreach (array_keys(reset($values)) as $column)
- {
- $columns[] = '? as '.$this->wrap($column);
- }
-
- $columns = array_fill(0, count($values), implode(', ', $columns));
-
- return "insert into $table ($names) select ".implode(' union select ', $columns);
- }
-
- /**
- * Compile a truncate table statement into SQL.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @return array
- */
- public function compileTruncate(Builder $query)
- {
- $sql = array('delete from sqlite_sequence where name = ?' => array($query->from));
-
- $sql['delete from '.$this->wrapTable($query->from)] = array();
-
- return $sql;
- }
-
- /**
- * Compile a "where day" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereDay(Builder $query, $where)
- {
- return $this->dateBasedWhere('%d', $query, $where);
- }
-
- /**
- * Compile a "where month" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereMonth(Builder $query, $where)
- {
- return $this->dateBasedWhere('%m', $query, $where);
- }
-
- /**
- * Compile a "where year" clause.
- *
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function whereYear(Builder $query, $where)
- {
- return $this->dateBasedWhere('%Y', $query, $where);
- }
-
- /**
- * Compile a date based where clause.
- *
- * @param string $type
- * @param \Illuminate\Database\Query\Builder $query
- * @param array $where
- * @return string
- */
- protected function dateBasedWhere($type, Builder $query, $where)
- {
- $value = str_pad($where['value'], 2, '0', STR_PAD_LEFT);
-
- $value = $this->parameter($value);
-
- return 'strftime(\''.$type.'\', '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
- }
-
-}