Add select and where clauses on the subquery.

@param  \Sofa\Eloquence\Searchable\Subquery $subquery
@param  \Sofa\Eloquence\Searchable\ColumnCollection $columns
@param  array $words
@param  float $threshold
@return void
963717
protected function addSearchClauses(
        SearchableSubquery $subquery,
        ColumnCollection $columns,
        array $words,
        $threshold
    ) {
        $whereBindings = $this->searchSelect($subquery, $columns, $words, $threshold);

        // For morphOne/morphMany support we need to port the bindings from JoinClauses.
        $joinBindings = collect($subquery->getQuery()->joins)->flatMap(function ($join) {
            return $join->getBindings();
        })->all();

        $this->addBinding($joinBindings, 'select');

        // Developer may want to skip the score threshold filtering by passing zero
        // value as threshold in order to simply order full result by relevance.
        // Otherwise we are going to add where clauses for speed improvement.
        if ($threshold > 0) {
            $this->searchWhere($subquery, $columns, $words, $whereBindings);
        }

        $this->query->where('relevance', '>=', new Expression(number_format($threshold, 2)));

        $this->query->orders = array_merge(
            [['column' => 'relevance', 'direction' => 'desc']],
            (array) $this->query->orders
        );
    }
622791
protected function whereSubquery(array $where)
    {
        return $this->wrap($where['column']) . ' ' . $where['operator'] . ' (' . $this->select($where['subquery']->getSQLStatement()) . ')';
    }
142739
protected function processSubQuery($subQuery, $context)
    {
        if ($subQuery instanceof Query) {
            return $this->processQuery($subQuery, $context);
        }

        return $subQuery;
    }
59165
public static String expandSubQuery(SubQuery subQuery, List<Object> values) {
		Table table = DOInfoReader.getTable(subQuery.getClazz());
		
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM (SELECT ");
		sql.append(subQuery.getField());
		sql.append(" FROM ").append(getTableName(table));
		sql.append(" ").append(SQLUtils.autoSetSoftDeleted(subQuery.getPostSql(), subQuery.getClazz()));
		sql.append(") sub ");
		
		if(subQuery.getArgs() != null) {
			values.addAll(Arrays.asList(subQuery.getArgs()));
		}
		return sql.toString();
	}
475641
public Where<T, ID> between(String columnName, Object low, Object high) throws SQLException {
		addClause(new Between(columnName, findColumnFieldType(columnName), low, high));
		return this;
	}
1059906
private function buildRequireArrayQuery($subclause, Builder $query)
    {
        if ($subclause['operator'] == 'IN') {
            $query->whereIn($subclause['to_value_column'], $subclause['value']);
        } elseif ($subclause['operator'] == 'NOT IN') {
            $query->whereNotIn($subclause['to_value_column'], $subclause['value']);
        } elseif ($subclause['operator'] == 'BETWEEN') {
            if (count($subclause['value']) !== 2) {
                throw new QBParseException($subclause['to_value_column'].
                    ' should be an array with only two items.');
            }

            $query->whereBetween($subclause['to_value_column'], $subclause['value']);
        } elseif ($subclause['operator'] == 'NOT BETWEEN') {
            if (count($subclause['value']) !== 2) {
                throw new QBParseException($subclause['to_value_column'].
                    ' should be an array with only two items.');
            }

            $query->whereNotBetween($subclause['to_value_column'], $subclause['value']);
        }

        return $query;
    }
747603
function _subWord($word)
    {
        static $sbox;
        if (empty($sbox)) {
            list(, , , , $sbox) = $this->_getTables();
        }

        return  $sbox[$word       & 0x000000FF]        |
               ($sbox[$word >>  8 & 0x000000FF] <<  8) |
               ($sbox[$word >> 16 & 0x000000FF] << 16) |
               ($sbox[$word >> 24 & 0x000000FF] << 24);
    }
123271
public function addSelectQuery(Criteria $subQueryCriteria, $alias = null)
    {
        if (null === $alias) {
            $alias = 'alias_' . ($subQueryCriteria->forgeSelectQueryAlias() + count($this->selectQueries));
        }
        $this->selectQueries[$alias] = $subQueryCriteria;

        return $this;
    }
309307
public function select($columns = [])
    {
        $expr = new ColumnExpression($this->sql);

        if ($columns instanceof Closure) {
            $columns($expr);
        } else {
            if (!is_array($columns)) {
                $columns = [$columns];
            }
            $expr->columns($columns);
        }
    }
635440
public function findWhere(array $where, $columns = ['*'])
    {
        $this->newQuery();

        foreach ($where as $field => $value) {
            if (is_array($value)) {
                list($field, $condition, $val) = $value;
                $this->query->where($field, $condition, $val);
            }
            else {
                $this->query->where($field, '=', $value);
            }
        }

        return $this->query->get($columns);
    }
740564
public function addSelect($columns) {
		if(is_array($columns))
			return $this->_addSelect($columns);

		$columns = explode(',', $columns);
		foreach($columns as $columnstr) {
			$columnstr = trim($columnstr);

			preg_match('/(.*?)\s+as\s+([a-z_][a-zA-Z0-9_]*)?$/i', $columnstr, $matches);
			if(isset($matches[2])) {
				$alias = $matches[2];
				$column = $matches[1];
			}
			else
				$alias = $column = $columnstr;

			if(isset($this->columns[$alias]))
				throw new \Exception('Column alias '.$alias.' is already used.');
			$this->columns[$alias] = $column;
		}

		return $this;
	}
257587
protected function filterTermsCondition($collection, $column)
    {
        if (!($value = $column->getFilter()->getValue())) {
            return;
        }

        $collection->setTermFilter($value);
    }
113398
public function filterQuery(&$selects)
    {
        $model      = $this->config->getDataModel();
        $joins      = $where      = '';
        $columnName = $this->getOption('column_name');

        $relationship = $model->{$this->getOption('relationship')}();
        $from_table   = $this->tablePrefix.$model->getTable();
        $field_table  = $columnName.'_'.$from_table;
        $other_table  = $this->tablePrefix.$relationship->getRelated()->getTable();
        $other_alias  = $columnName.'_'.$other_table;
        $other_model  = $relationship->getRelated();
        $other_key    = $other_model->getKeyName();
        $int_table    = $this->tablePrefix.$relationship->getTable();
        $int_alias    = $columnName.'_'.$int_table;
        $column1      = explode('.', $relationship->getForeignKey());
        $column1      = $column1[1];
        $column2      = explode('.', $relationship->getOtherKey());
        $column2      = $column2[1];
        $joins .= ' LEFT JOIN '.$int_table.' AS '.$int_alias.' ON '.$int_alias.'.'.$column1.' = '.$field_table.'.'.$model->getKeyName()
                .' LEFT JOIN '.$other_table.' AS '.$other_alias.' ON '.$other_alias.'.'.$other_key.' = '.$int_alias.'.'.$column2;

        //grab the existing where clauses that the user may have set on the relationship
        $relationshipWheres = $this->getRelationshipWheres($relationship, $other_alias, $int_alias, $int_table);

        $where = $this->tablePrefix.$model->getTable().'.'.$model->getKeyName().' = '.$int_alias.'.'.$column1
                    .($relationshipWheres ? ' AND '.$relationshipWheres : '');

        $selects[] = $this->db->raw('(SELECT '.$this->getOption('select').'
										FROM '.$from_table.' AS '.$field_table.' '.$joins.'
										WHERE '.$where.') AS '.$this->db->getQueryGrammar()->wrap($columnName));
    }
1128765
protected function filterStoreCondition($collection, $column)
    {
        if (!($value = $column->getFilter()->getValue())) {
            return;
        }

        $collection->addStoreFilter($value);
    }
362713
protected function select(array $fields, array $criteria = array(), array $operators = array(), array $conditions = array())
    {
        $sql = "";
        $stringConditions = array();
        
        if ((!empty($criteria) && !empty($operators)) && !empty($conditions)) {
            if ((count($criteria) == count($operators) && (count($criteria) - 1) == count($conditions)) 
                && ((count($operators) -1) != count($conditions) && count($criteria) > 1)) {
                throw new \Exception("The number of Criteria, Operators and Conditions are not equals.");
            }
            
            $criteriaFields = array_keys($criteria);
            
            $stringConditions[] = "$criteriaFields[0] $operators[0] ?";
            
            for ($i = 1; $i < count($criteriaFields); $i++) {
                $j = $i - 1;
                $stringConditions[] = "$conditions[$j] $criteriaFields[$i] $operators[$i] ?";
            }
            
            $sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table " 
                . "WHERE " . implode(' ', $stringConditions);
        } elseif ((!empty($criteria) && !empty($operators)) && count($criteria) > 1) {
            if (count($criteria) != count($operators)) {
                throw new \Exception("The number of Criteria and Operators are not equals.");
            }
            
            $criteriaFields = array_keys($criteria);
            
            for ($i = 0; $i < count($criteriaFields); $i++) {
                $stringConditions[] = "$criteriaFields[$i] $operators[$i] ?";
            }
            
            $sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table " 
                . "WHERE " . implode(' AND ', $stringConditions);
        } elseif (!empty($criteria)) {
            foreach ($criteria as $field => $value) {
                $stringConditions[] = "$field = ?";
            }
            
            $sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table " 
                . "WHERE " . implode(' AND ', $stringConditions);
        } elseif (!empty($fields)) {
            $sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table";
        }
        
        $pdos = $this->_pdo->prepare($sql);
        $pdos->execute(array_values($criteria));
        
        return $pdos->fetchAll();
    }
394481
public function selectQuery(string $prefix, array $from = [], array $columns = []): SelectQuery
    {
        return new SelectQuery($this, $this->getCompiler($prefix), $from, $columns);
    }
1355493
public function multiFilterBy($columns)
    {
        foreach ($columns as $column => $value) {
            if (strpos($column, '.')) {
                $this->filterByRelation($column, $value);
            } else {
                $this->filterBy($column, $value);
            }
        }

        return $this;
    }