8889841cPK[PB$)Concerns/OffsetStatement.phpnu[offset = (int)$offset; return $this; } protected function getOffsetSQL() { return $this->limit && $this->offset ? ["OFFSET {$this->offset}"] : []; } } PK[}߅Concerns/TablePrefix.phpnu[ $wpdb->users, 'usermeta' => $wpdb->usermeta, ]; if ($table instanceof RawSQL) { return $table->sql; } if (array_key_exists($table, $sharedTables)) { return $sharedTables[ $table ]; } return $wpdb->prefix . $table; } } PK[X Concerns/UnionOperator.phpnu[unions = array_map(function (QueryBuilder $builder) { return new Union($builder); }, $union); return $this; } /** * @param QueryBuilder $union * * @return $this */ public function unionAll(...$union) { $this->unions = array_map(function (QueryBuilder $builder) { return new Union($builder, true); }, $union); return $this; } /** * @return array|string[] */ protected function getUnionSQL() { if (empty($this->unions)) { return []; } return array_map(function (Union $union) { return ( $union->all ? 'UNION ALL ' : 'UNION ' ) . $union->builder->getSQL(); }, $this->unions); } } PK[KdConcerns/Aggregate.phpnu[selects)) { $this->selects[] = new RawSQL('SELECT COUNT(%1s) AS count', $column); } else { $this->selects[] = new RawSQL('COUNT(%1s) AS count', $column); } return +$this->get()->count; } /** * Returns the total sum in a set of values * * @since 2.19.0 * @param string $column * * @return int|float */ public function sum($column) { $this->selects[] = new RawSQL('SELECT SUM(%1s) AS sum', $column); return +$this->get()->sum; } /** * Get the average value in a set of values * * @since 2.19.0 * @param string $column * * @return int|float */ public function avg($column) { $this->selects[] = new RawSQL('SELECT AVG(%1s) AS avg', $column); return +$this->get()->avg; } /** * Returns the minimum value in a set of values * * @since 2.19.0 * @param string $column * * @return int|float */ public function min($column) { $this->selects[] = new RawSQL('SELECT MIN(%1s) AS min', $column); return +$this->get()->min; } /** * Returns the maximum value in a set of values * * @since 2.19.0 * @param string $column * * @return int|float */ public function max($column) { $this->selects[] = new RawSQL('SELECT MAX(%1s) AS max', $column); return +$this->get()->max; } } PK[sGEttConcerns/MetaQuery.phpnu[metaTablesConfigs[] = new MetaTable( $table, $metaKeyColumn, $metaValueColumn ); return $this; } /** * @param string|RawSQL $table * * @return MetaTable */ protected function getMetaTable($table) { $tableName = QueryBuilder::prefixTable($table); foreach ($this->metaTablesConfigs as $metaTable) { if ($metaTable->tableName === $tableName) { return $metaTable; } } return new MetaTable( $table, $this->defaultMetaKeyColumn, $this->defaultMetaValueColumn ); } /** * Select meta columns * * @since 2.21.1 optimize group concat functionality * @since 2.19.6 add group concat functionality * @since 2.19.0 * * @param string|RawSQL $table * @param string $foreignKey * @param string $primaryKey * @param array $columns * * @return $this */ public function attachMeta($table, $foreignKey, $primaryKey, ...$columns) { $metaTable = $this->getMetaTable($table); foreach ($columns as $i => $definition) { if (is_array($definition)) { list ($column, $columnAlias, $concat) = array_pad($definition, 3, false); } else { $column = $definition; $columnAlias = $concat = false; } // Set dynamic alias $tableAlias = sprintf('%s_%s_%s', ($table instanceof RawSQL) ? $table->sql : $table, 'attach_meta', $columnAlias ?: $column); // Check if we have meta columns that dev wants to group concat if ($concat) { /** * Include foreign key to prevent errors if sql_mode is only_full_group_by * * @see https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html */ $this->groupBy($foreignKey); // Group concat same key values into faux array // @example key => ["value1", "value2"] $this->selectRaw( "CONCAT('[',GROUP_CONCAT(DISTINCT CONCAT('\"',%1s,'\"')),']') AS %2s", $tableAlias . '.' . $metaTable->valueColumnName, $columnAlias ?: $column ); } else { $this->select(["{$tableAlias}.{$metaTable->valueColumnName}", $columnAlias ?: $column]); } $this->join( function (JoinQueryBuilder $builder) use ( $table, $foreignKey, $primaryKey, $tableAlias, $column, $metaTable ) { $builder ->leftJoin($table, $tableAlias) ->on($foreignKey, "{$tableAlias}.{$primaryKey}") ->andOn("{$tableAlias}.{$metaTable->keyColumnName}", $column, true); } ); } return $this; } } PK[*5 5 Concerns/CRUD.phpnu[getTable(), $data, $format ); } /** * @see https://developer.wordpress.org/reference/classes/wpdb/update/ * * @since 2.19.0 * * @param null $format * * @param array $data * @return false|int * */ public function update($data, $format = null) { return DB::update( $this->getTable(), $data, $this->getWhere(), $format, null ); } /** * @since 2.19.0 * * @return false|int * * @see https://developer.wordpress.org/reference/classes/wpdb/delete/ */ public function delete() { return DB::delete( $this->getTable(), $this->getWhere(), null ); } /** * Get results * * @since 2.19.0 * * @param string ARRAY_A|ARRAY_N|OBJECT|OBJECT_K $output * * @return array|object|null */ public function getAll($output = OBJECT) { return DB::get_results($this->getSQL(), $output); } /** * Get row * * @since 2.19.0 * * @param string ARRAY_A|ARRAY_N|OBJECT|OBJECT_K $output * * @return array|object|null */ public function get($output = OBJECT) { return DB::get_row($this->getSQL(), $output); } /** * Get a single column's value from the first result of a query. * * @since 2.24.0 * * @param string $column * * @return mixed */ public function value(string $column) { $result = (array) $this->select($column)->get(); return count($result) > 0 ? $result[$column] : null; } /** * @since 2.19.0 * * @return string */ private function getTable() { return $this->froms[0]->table; } /** * @since 2.19.0 * * @return array[] */ private function getWhere() { $wheres = []; foreach ($this->wheres as $where) { $wheres[$where->column] = $where->value; } return $wheres; } } PK[7?Concerns/OrderByStatement.phpnu[orderBys[] = new OrderBy($column, $direction); return $this; } /** * @return array|string[] */ protected function getOrderBySQL() { if (empty($this->orderBys)) { return []; } $orderBys = implode( ', ', array_map(function (OrderBy $order) { return DB::prepare('%1s %2s', $order->column, $order->direction); }, $this->orderBys) ); return ['ORDER BY ' . $orderBys]; } } PK[11Concerns/WhereClause.phpnu[getSQL(); array_shift($wheres); $this->wheres[] = sprintf( "%s (%s)", empty($this->wheres) ? null : $logicalOperator, implode(' ', $wheres) ); } // If the value is a Closure instance, we will assume the developer is performing an entire sub-select within the query elseif ($value instanceof Closure) { $builder = new QueryBuilder(); call_user_func($value, $builder); $this->wheres[] = sprintf( "%s %s %s (%s)", empty($this->wheres) ? null : $logicalOperator, $column, $comparisonOperator, $builder->getSQL() ); } // Standard WHERE clause else { $this->wheres[] = new Where( $column, $value, $comparisonOperator, empty($this->wheres) ? null : $logicalOperator ); } return $this; } /** * @param string|Closure $column The closure will receive a Give\Framework\QueryBuilder\WhereQueryBuilder instance * @param string|Closure|array|null $value The closure will receive a Give\Framework\QueryBuilder\QueryBuilder instance * @param string $comparisonOperator * * @return $this */ public function where($column, $value = null, $comparisonOperator = '=') { return $this->setWhere( $column, $value, $comparisonOperator, Operator::_AND ); } /** * @param string|Closure $column * @param string|Closure|array|null $value * @param string $comparisonOperator * * @return $this */ public function orWhere($column, $value = null, $comparisonOperator = '=') { return $this->setWhere( $column, $value, $comparisonOperator, Operator::_OR ); } /** * @param string $column * @param array|Closure $value * * @return $this */ public function whereIn($column, $value) { return $this->where( $column, $value, Operator::IN ); } /** * @param string $column * @param array|Closure $value * * @return $this */ public function orWhereIn($column, $value) { return $this->orWhere( $column, $value, Operator::IN ); } /** * @param string $column * @param array|Closure $value * * @return $this */ public function whereNotIn($column, $value) { return $this->where( $column, $value, Operator::NOTIN ); } /** * @param string $column * @param array|Closure $value * * @return $this */ public function orWhereNotIn($column, $value) { return $this->orWhere( $column, $value, Operator::NOTIN ); } /** * @param string $column * @param string|int $min * @param string|int $max * * @return $this */ public function whereBetween($column, $min, $max) { return $this->where( $column, [$min, $max], Operator::BETWEEN ); } /** * @param string $column * @param string|int $min * @param string|int $max * * @return $this */ public function whereNotBetween($column, $min, $max) { return $this->where( $column, [$min, $max], Operator::NOTBETWEEN ); } /** * @param string $column * @param string|int $min * @param string|int $max * * @return $this */ public function orWhereBetween($column, $min, $max) { return $this->orWhere( $column, [$min, $max], Operator::BETWEEN ); } /** * @param string $column * @param string|int $min * @param string|int $max * * @return $this */ public function orWhereNotBetween($column, $min, $max) { return $this->orWhere( $column, [$min, $max], Operator::NOTBETWEEN ); } /** * @param string $column * @param string $value * * @return $this */ public function whereLike($column, $value) { return $this->where( $column, $value, Operator::LIKE ); } /** * @param string $column * @param string $value * * @return $this */ public function whereNotLike($column, $value) { return $this->where( $column, $value, Operator::NOTLIKE ); } /** * @param string $column * @param string $value * * @return $this */ public function orWhereLike($column, $value) { return $this->orWhere( $column, $value, Operator::LIKE ); } /** * @param string $column * @param string $value * * @return $this */ public function orWhereNotLike($column, $value) { return $this->orWhere( $column, $value, Operator::NOTLIKE ); } /** * @param string $column * * @return $this */ public function whereIsNull($column) { return $this->where( $column, null, Operator::ISNULL ); } /** * @param string $column * * @return $this */ public function orWhereIsNull($column) { return $this->orWhere( $column, null, Operator::ISNULL ); } /** * @param string $column * * @return $this */ public function whereIsNotNull($column) { return $this->where( $column, null, Operator::NOTNULL ); } /** * @param string $column * * @return $this */ public function orWhereIsNotNull($column) { return $this->orWhere( $column, null, Operator::NOTNULL ); } /** * @param Closure $callback The closure will receive a Give\Framework\QueryBuilder\QueryBuilder instance * * @return QueryBuilder|WhereQueryBuilder */ public function whereExists($callback) { return $this->where( null, $callback, Operator::EXISTS ); } /** * @param Closure $callback The closure will receive a Give\Framework\QueryBuilder\QueryBuilder instance * * @return QueryBuilder|WhereQueryBuilder */ public function whereNotExists($callback) { return $this->where( null, $callback, Operator::NOTEXISTS ); } /** * Add raw SQL WHERE clause * * @param $sql * @param ...$args * * @return $this */ public function whereRaw($sql, ...$args) { $this->wheres[] = new RawSQL($sql, $args); return $this; } /** * @return string[] */ protected function getWhereSQL() { // Bailout if (empty($this->wheres)) { return []; } $wheres = []; foreach ($this->wheres as $i => $where) { if ($where instanceof RawSQL) { if ($i === 0) { // If the first element is an instance of RawSQL // then we don't need the starting WHERE keyword because we assume that the dev will include that in RawSQL $this->includeWhereKeyword = false; } $wheres[] = $where->sql; continue; } if ($where instanceof Where) { $wheres[] = $this->buildWhereSQL($where); continue; } // If the variable $where is not an instance of the Where class // it means the SQL is already generated by the Query Builder, so we just return that $wheres[] = $where; } if ($this->includeWhereKeyword) { return array_merge(['WHERE'], $wheres); } return $wheres; } /** * @param Where $where * * @return string */ private function buildWhereSQL(Where $where) { switch ($where->comparisonOperator) { // Handle membership conditions case Operator::IN: case Operator::NOTIN: return DB::prepare( "%1s %2s %3s", $where->logicalOperator, $where->column, $where->comparisonOperator ) . ' (' . implode( ',', array_map(function ($where) { return DB::prepare('%s', $where); }, $where->value) ) . ')'; // Handle BETWEEN conditions case Operator::BETWEEN: case Operator::NOTBETWEEN: list($min, $max) = $where->value; return DB::prepare( "%1s %2s %3s %s AND %s", $where->logicalOperator, $where->column, $where->comparisonOperator, $min, $max ); // Handle LIKE conditions case Operator::LIKE: case Operator::NOTLIKE: return DB::prepare( "%1s %2s %3s %s", $where->logicalOperator, $where->column, $where->comparisonOperator, strpos($where->value, '%') !== false ? $where->value : '%' . $where->value . '%' ); // Handle NULL conditions case Operator::ISNULL: case Operator::NOTNULL: return DB::prepare( "%1s %2s %3s", $where->logicalOperator, $where->column, $where->comparisonOperator ); // Standard WHERE clause default: return DB::prepare( "%1s %2s %3s %s", $where->logicalOperator, $where->column, $where->comparisonOperator, $where->value ); } } } PK[ Concerns/GroupByStatement.phpnu[groupByColumns, true)) { $this->groupByColumns[] = DB::prepare('%1s', $tableColumn); } return $this; } protected function getGroupBySQL() { return !empty($this->groupByColumns) ? ['GROUP BY ' . implode(',', $this->groupByColumns)] : []; } } PK[w_n Concerns/LimitStatement.phpnu[limit = (int)$limit; return $this; } protected function getLimitSQL() { return $this->limit ? ["LIMIT {$this->limit}"] : []; } } PK[joins[] = $callback; return $this; } /** * @param string|RawSQL $table * @param string $column1 * @param string $column2 * @param string|null $alias * * @return $this */ public function leftJoin($table, $column1, $column2, $alias = null) { $this->join( function (JoinQueryBuilder $builder) use ($table, $column1, $column2, $alias) { $builder ->leftJoin($table, $alias) ->on($column1, $column2); } ); return $this; } /** * @param string|RawSQL $table * @param string $column1 * @param string $column2 * @param string|null $alias * * @return $this */ public function innerJoin($table, $column1, $column2, $alias = null) { $this->join( function (JoinQueryBuilder $builder) use ($table, $column1, $column2, $alias) { $builder ->innerJoin($table, $alias) ->on($column1, $column2); } ); return $this; } /** * @param string|RawSQL $table * @param string $column1 * @param string $column2 * @param string|null $alias * * @return $this */ public function rightJoin($table, $column1, $column2, $alias = null) { $this->join( function (JoinQueryBuilder $builder) use ($table, $column1, $column2, $alias) { $builder ->rightJoin($table, $alias) ->on($column1, $column2); } ); return $this; } /** * Add raw SQL JOIN clause * * @param string $sql * @param ...$args * * @return $this; */ public function joinRaw($sql, ...$args) { $this->joins[] = new RawSQL($sql, $args); return $this; } /** * @return string[] */ protected function getJoinSQL() { return array_map(function ($callback) { if ($callback instanceof RawSQL) { return $callback->sql; } $builder = new JoinQueryBuilder(); call_user_func($callback, $builder); $joins = array_map(function ($join) { if ($join instanceof RawSQL) { return $join->sql; } if ($join instanceof Join) { if ($join->alias) { return DB::prepare( '%1s JOIN %2s %3s', $join->joinType, $join->table, $join->alias ); } return DB::prepare( '%1s JOIN %2s', $join->joinType, $join->table ); } // JoinCondition return DB::prepare( $join->quote ? ' %1s %2s = %s' : ' %1s %2s = %3s', $join->logicalOperator, $join->column1, $join->column2 ); }, $builder->getDefinedJoins()); return implode(' ', $joins); }, $this->joins); } } PK[H Concerns/SelectStatement.phpnu[selects = array_merge($this->selects, $selects); return $this; } /** * Add raw SQL SELECT statement * * @param string $sql * @param ...$args */ public function selectRaw($sql, ...$args) { $this->selects[] = new RawSQL($sql, $args); return $this; } /** * Select distinct * * @return $this */ public function distinct() { $this->distinct = true; return $this; } /** * @return string[] */ protected function getSelectSQL() { // Select all by default if (empty($this->selects)) { $this->select('*'); } $selects = []; foreach ($this->selects as $i => $select) { if ($select instanceof RawSQL) { if ($i === 0) { // If the first element is an instance of RawSQL // then we don't need the starting SELECT keyword because we assume that the dev will include that in RawSQL $this->includeSelectKeyword = false; } $selects[] = $select->sql; continue; } if ($select->alias) { $selects[] = DB::prepare( '%1s AS %2s', $select->column, $select->alias ); continue; } $selects[] = DB::prepare('%1s', $select->column); } $selectStatements = implode(', ', $selects); if ($this->includeSelectKeyword) { $keyword = 'SELECT '; if ($this->distinct) { $keyword .= 'DISTINCT '; } return [$keyword . $selectStatements]; } return [$selectStatements]; } } PK[kConcerns/FromClause.phpnu[froms[] = new From($table, $alias); return $this; } /** * @return array|string[] */ protected function getFromSQL() { if (empty($this->froms)) { return []; } return [ 'FROM ' . implode( ', ', array_map(function (From $from) { if ($from->alias) { return DB::prepare( '%1s AS %2s', $from->table, $from->alias ); } return DB::prepare('%1s', $from->table); }, $this->froms) ) ]; } } PK[TL?Concerns/HavingClause.phpnu[havings[] = new Having( $column, $comparisonOperator, $value, empty($this->havings) ? null : Operator::_AND, $mathFunction ); return $this; } /** * @param string $column * @param string $comparisonOperator * @param string $value * @param null|string $mathFunction \Give\Framework\QueryBuilder\Types\Math * * @return $this */ public function orHaving($column, $comparisonOperator, $value, $mathFunction = null) { $this->havings[] = new Having( $column, $comparisonOperator, $value, empty($this->havings) ? null : Operator::_OR, $mathFunction ); return $this; } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function havingCount($column, $comparisonOperator, $value) { return $this->having( $column, $comparisonOperator, $value, Math::COUNT ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function orHavingCount($column, $comparisonOperator, $value) { return $this->orHaving( $column, $comparisonOperator, $value, Math::COUNT ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function havingMin($column, $comparisonOperator, $value) { return $this->having( $column, $comparisonOperator, $value, Math::MIN ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function orHavingMin($column, $comparisonOperator, $value) { return $this->orHaving( $column, $comparisonOperator, $value, Math::MIN ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function havingMax($column, $comparisonOperator, $value) { return $this->having( $column, $comparisonOperator, $value, Math::MAX ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function orHavingMax($column, $comparisonOperator, $value) { return $this->orHaving( $column, $comparisonOperator, $value, Math::MAX ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function havingAvg($column, $comparisonOperator, $value) { return $this->having( $column, $comparisonOperator, $value, Math::AVG ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function orHavingAvg($column, $comparisonOperator, $value) { return $this->orHaving( $column, $comparisonOperator, $value, Math::AVG ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function havingSum($column, $comparisonOperator, $value) { return $this->having( $column, $comparisonOperator, $value, Math::SUM ); } /** * @param string $column * @param string $comparisonOperator * @param string|int $value * * @return $this */ public function orHavingSum($column, $comparisonOperator, $value) { return $this->orHaving( $column, $comparisonOperator, $value, Math::SUM ); } /** * Add raw SQL HAVING clause * * @param string $sql * @param ...$args * * @return $this */ public function havingRaw($sql, ...$args) { $this->havings[] = new RawSQL($sql, $args); return $this; } /** * @return string[] */ protected function getHavingSQL() { if (empty($this->havings)) { return []; } $havings = []; foreach ($this->havings as $i => $having) { if ($having instanceof RawSQL) { if ($i === 0) { // If the first element is an instance of RawSQL // then we don't need the starting HAVING keyword because we assume that the dev will include that in RawSQL $this->includeHavingKeyword = false; } $havings[] = $having->sql; continue; } $havings[] = $this->buildHavingSQL($having); } if ($this->includeHavingKeyword) { return array_merge(['HAVING'], $havings); } return $havings; } /** * @param Having $having * * @return string */ private function buildHavingSQL(Having $having) { if ($having->mathFunction) { return DB::prepare( "%1s %2s(%3s) %4s %s", $having->logicalOperator, $having->mathFunction, $having->column, $having->comparisonOperator, $having->value ); } return DB::prepare( "%1s %2s %3s %s", $having->logicalOperator, $having->column, $having->comparisonOperator, $having->value ); } } PK[Gw) JoinQueryBuilder.phpnu[join( JoinType::LEFT, $table, $alias ); } /** * @param string|RawSQL $table * @param null|string $alias * * @return $this */ public function rightJoin($table, $alias = null) { return $this->join( JoinType::RIGHT, $table, $alias ); } /** * @param string|RawSQL $table * @param null|string $alias * * @return $this */ public function innerJoin($table, $alias = null) { return $this->join( JoinType::INNER, $table, $alias ); } /** * @param string $column1 * @param string $column2 * @param bool $quote * * @return $this */ public function on($column1, $column2, $quote = false) { return $this->joinCondition( Operator::ON, $column1, $column2, $quote ); } /** * @param string $column1 * @param string $column2 * @param bool $quote * * @return $this */ public function andOn($column1, $column2, $quote = null) { return $this->joinCondition( Operator::_AND, $column1, $column2, $quote ); } /** * @param string $column1 * @param string $column2 * @param bool $quote * * @return $this */ public function orOn($column1, $column2, $quote = null) { return $this->joinCondition( Operator::_OR, $column1, $column2, $quote ); } /** * Add raw SQL JOIN clause * * @param string $sql * @param ...$args */ public function joinRaw($sql, ...$args) { $this->joins[] = new RawSQL($sql, $args); } /** * Add Join * * @param string $joinType * @param string|RawSQL $table * @param string $alias * * @return $this */ private function join($joinType, $table, $alias) { $this->joins[] = new Join( $joinType, $table, $alias ); return $this; } /** * Add JoinCondition * * @param string $operator * @param string $column1 * @param string $column2 * @param bool $quote * * @return $this */ private function joinCondition($operator, $column1, $column2, $quote) { $this->joins[] = new JoinCondition( $operator, $column1, $column2, $quote ); return $this; } /** * @return Join[]|JoinCondition[] */ public function getDefinedJoins() { return $this->joins; } } PK[\''WhereQueryBuilder.phpnu[getWhereSQL(); } } PK[j`{ { Clauses/Having.phpnu[column = trim($column); $this->comparisonOperator = $this->getComparisonOperator($comparisonOperator); $this->value = $value; $this->logicalOperator = $logicalOperator ? $this->getLogicalOperator($logicalOperator) : ''; $this->mathFunction = $this->getMathFunction($mathFunction); } /** * @param string $logicalOperator * * @return string */ private function getLogicalOperator($logicalOperator) { $operators = [ Operator::_AND, Operator::_OR ]; $logicalOperator = strtoupper($logicalOperator); if ( ! in_array($logicalOperator, $operators, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported logical operator %s. Please use one of the supported operators (%s)', $logicalOperator, implode(',', $operators) ) ); } return $logicalOperator; } /** * @param string $comparisonOperator * * @return string */ private function getComparisonOperator($comparisonOperator) { $operators = [ '<', '<=', '>', '>=', '<>', '!=', '=' ]; if ( ! in_array($comparisonOperator, $operators, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported comparison operator %s. Please use one of the supported operators (%s)', $comparisonOperator, implode(',', $operators) ) ); } return $comparisonOperator; } /** * @param string $mathFunction * * @return string */ private function getMathFunction($mathFunction) { if (array_key_exists($mathFunction, Math::getTypes())) { return $mathFunction; } return null; } } PK[ eLClauses/From.phpnu[table = QueryBuilder::prefixTable($table); $this->alias = trim($alias); } } PK[Clauses/Union.phpnu[builder = $builder; $this->all = $all; } } PK[x Clauses/Where.phpnu[column = trim($column); $this->value = $value; $this->comparisonOperator = $this->getComparisonOperator($comparisonOperator); $this->logicalOperator = $logicalOperator ? $this->getLogicalOperator($logicalOperator) : ''; } /** * @param string $comparisonOperator * * @return string */ private function getComparisonOperator($comparisonOperator) { $operators = [ '<', '<=', '>', '>=', '<>', '!=', '=', Operator::LIKE, Operator::NOTLIKE, Operator::IN, Operator::NOTIN, Operator::BETWEEN, Operator::NOTBETWEEN, Operator::ISNULL, Operator::NOTNULL ]; if (!in_array($comparisonOperator, $operators, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported comparison operator %s. Please use one of the supported operators (%s)', $comparisonOperator, implode(',', $operators) ) ); } return $comparisonOperator; } /** * @param string $logicalOperator * * @return string */ private function getLogicalOperator($logicalOperator) { $operators = [ Operator::_AND, Operator::_OR ]; $logicalOperator = strtoupper($logicalOperator); if (!in_array($logicalOperator, $operators, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported logical operator %s. Please use one of the supported operators (%s)', $logicalOperator, implode(',', $operators) ) ); } return $logicalOperator; } } PK[J44Clauses/JoinCondition.phpnu[logicalOperator = $this->getLogicalOperator($logicalOperator); $this->column1 = trim($column1); $this->column2 = trim($column2); $this->quote = $quote; } /** * @param string $operator * * @return string */ private function getLogicalOperator($operator) { $operator = strtoupper($operator); $supportedOperators = [ Operator::ON, Operator::_AND, Operator::_OR ]; if ( ! in_array($operator, $supportedOperators, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported logical operator %s. Please provide one of the supported operators (%s)', $operator, implode(',', $supportedOperators) ) ); } return $operator; } } PK[R"++Clauses/OrderBy.phpnu[column = trim($column); $this->direction = $this->getSortDirection($direction); } /** * @param string $direction * * @return string */ private function getSortDirection($direction) { $direction = strtoupper($direction); $directions = ['ASC', 'DESC']; if ( ! in_array($direction, $directions, true)) { throw new InvalidArgumentException( sprintf( 'Unsupported sort direction %s. Please use one of the (%s)', $direction, implode(',', $directions) ) ); } return $direction; } } PK[MClauses/MetaTable.phpnu[tableName = QueryBuilder::prefixTable($table); $this->keyColumnName = trim($metaKeyColumnName); $this->valueColumnName = trim($metaValueColumnName); } } PK[b\d##Clauses/Join.phpnu[table = QueryBuilder::prefixTable($table); $this->joinType = $this->getJoinType($joinType); $this->alias = trim($alias); } /** * @param string $type * * @return string */ private function getJoinType($type) { $type = strtoupper($type); if (array_key_exists($type, JoinType::getTypes())) { return $type; } throw new InvalidArgumentException( sprintf( 'Join type %s is not supported. Please provide one of the supported join types (%s)', $type, implode(',', JoinType::getTypes()) ) ); } } PK[eX1GClauses/Select.phpnu[column = trim($column); $this->alias = trim($alias); } } PK[i||Clauses/RawSQL.phpnu[sql = $args ? DB::prepare($sql, $args) : $sql; } } PK[88Types/Type.phpnu[getConstants(); } } PK[WTypes/Math.phpnu[getSelectSQL(), $this->getFromSQL(), $this->getJoinSQL(), $this->getWhereSQL(), $this->getGroupBySQL(), $this->getHavingSQL(), $this->getOrderBySQL(), $this->getLimitSQL(), $this->getOffsetSQL(), $this->getUnionSQL() ); // Trim double spaces added by DB::prepare return str_replace( [' ', ' '], ' ', implode(' ', $sql) ); } } PK[PB$)Concerns/OffsetStatement.phpnu[PK[}߅?Concerns/TablePrefix.phpnu[PK[X QConcerns/UnionOperator.phpnu[PK[Kd) Concerns/Aggregate.phpnu[PK[sGEtt Concerns/MetaQuery.phpnu[PK[*5 5 !Concerns/CRUD.phpnu[PK[7?=,Concerns/OrderByStatement.phpnu[PK[11R0Concerns/WhereClause.phpnu[PK[ aConcerns/GroupByStatement.phpnu[PK[w_n dConcerns/LimitStatement.phpnu[PK[