Query
class Query
Query builder.
Properties
| protected Connection | $connection | Database connection. | |
| protected HelperInterface | $helper | Query helper. | |
| protected Compiler | $compiler | Query compiler. | |
| protected mixed | $table | Database table. | |
| protected bool | $distinct | Select distinct? | |
| protected array | $commonTableExpressions | Common table expressions. | |
| protected array | $setOperations | Set operations. | |
| protected array | $columns | Columns from which we are fetching data. | |
| protected array | $wheres | WHERE clauses. | |
| protected array | $joins | JOIN clauses. | |
| protected array | $groupings | GROUP BY clauses. | |
| protected array | $havings | HAVING clauses. | |
| protected array | $orderings | ORDER BY clauses. | |
| protected int|null | $limit | Limit. | |
| protected int|null | $offset | Offset. | |
| protected bool|string|null | $lock | Lock. | |
| protected string|null | $prefix | Prefix. | |
| protected bool | $inSubqueryContext | Is the query in subquery context? | |
| static protected PaginationFactoryInterface|Closure | $paginationFactory | Pagination factory. | 
Methods
Create a fresh compiler instance and clone set operation queries when we clone the query.
Resets the query to its default state.
Returns a new query builder instance.
Sets the query to subquery context.
Gets the pagination factory.
Returns the connection instance.
Returns query compiler instance.
Returns the common set operations.
Returns the set operations.
Returns the database table.
Is it a distict select?
Returns the columns from which we are fetching data.
Returns WHERE clauses.
Returns JOIN clauses.
Returns GROUP BY clauses.
Returns HAVING clauses.
Returns ORDER BY clauses.
Returns the limit.
Returns the offset.
Returns the lock.
Returns the prefix.
Executes the closure if the compiler is of the correct class.
Adds a recursive common table expression.
Adds a set operation.
Adds a UNION operation.
Adds a UNION ALL operation.
Adds a INTERSECT operation.
Adds a INTERSECT ALL operation.
Adds a EXCEPT operation.
Adds a EXCEPT ALL operation.
Sets the columns we want to select.
Sets the columns we want to select using raw SQL.
Select distinct?
Adds a raw WHERE clause.
Adds a raw OR WHERE clause.
Adds a date comparison clause.
Adds a date comparison clause.
Adds a column comparison clause.
Adds a column comparison clause.
Adds a BETWEEN clause.
Adds a OR BETWEEN clause.
Adds a NOT BETWEEN clause.
Adds a OR NOT BETWEEN clause.
Adds a date range clause.
Adds a date range clause.
Adds a date range clause.
Adds a date range clause.
Adds a IS NULL clause.
Adds a OR IS NULL clause.
Adds a IS NOT NULL clause.
Adds a OR IS NOT NULL clause.
Adds a raw JOIN clause.
Adds a raw LEFT OUTER JOIN clause.
Adds a GROUP BY clause.
Adds a HAVING clause.
Adds a raw HAVING clause.
Adds a OR HAVING clause.
Adds a raw OR HAVING clause.
Adds a ORDER BY clause.
Adds a raw ORDER BY clause.
Adds an ascending ORDER BY clause.
Adds a raw ascending ORDER BY clause.
Adds a descending ORDER BY clause.
Adds a raw descending ORDER BY clause.
Clears the ordering clauses.
Adds a LIMIT clause.
Adds a OFFSET clause.
Enable lock.
Enable shared lock.
Adds a query prefix.
Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.
Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.
Creates a result set.
Executes a SELECT query and returns an array containing all of the result set rows.
Executes a SELECT query and returns the value of the chosen column of the first row of the result set.
Executes a SELECT query and returns an array containing the values of the indicated 0-indexed column.
Executes a SELECT query and returns an array where the first column is used as keys and the second as values.
Executes a SELECT query and returns a generator that lets you iterate over the results.
Executes a SELECT query and returns a generator that lets you iterate over the results.
Returns the number of records that the query will return.
Paginates the results using a pagination instance.
Sets the selected column of the query to the chosen aggreate.
Returns the minimum value for the chosen column.
Returns the maximum value for the chosen column.
Returns sum of all the values in the chosen column.
Returns the average value for the chosen column.
Returns the number of rows.
Returns the number of distinct values of the chosen column.
Inserts data into the chosen table.
Inserts data into the chosen table and returns the auto increment id.
Updates data from the chosen table.
Increments column value.
Decrements column value.
Deletes data from the chosen table.
Details
        at         line 170
                            
    __construct(Connection $connection)
        
    
    Constructor.
        at         line 182
                            
    __clone()
        
    
    Create a fresh compiler instance and clone set operation queries when we clone the query.
        at         line 195
                    protected        
    reset()
        
    
    Resets the query to its default state.
        at         line 210
                            Query
    newInstance()
        
    
    Returns a new query builder instance.
        at         line 220
                            $this
    inSubqueryContext()
        
    
    Sets the query to subquery context.
        at         line 232
                static            
    setPaginationFactory(PaginationFactoryInterface|Closure $factory)
        
    
    Sets the pagination factory.
        at         line 242
                static            PaginationFactoryInterface
    getPaginationFactory()
        
    
    Gets the pagination factory.
        at         line 259
                            Connection
    getConnection()
        
    
    Returns the connection instance.
        at         line 269
                            Compiler
    getCompiler()
        
    
    Returns query compiler instance.
        at         line 279
                            array
    getCommonTableExpressions()
        
    
    Returns the common set operations.
        at         line 289
                            array
    getSetOperations()
        
    
    Returns the set operations.
        at         line 299
                            mixed
    getTable()
        
    
    Returns the database table.
        at         line 309
                            bool
    isDistinct()
        
    
    Is it a distict select?
        at         line 319
                            array
    getColumns()
        
    
    Returns the columns from which we are fetching data.
        at         line 329
                            array
    getWheres()
        
    
    Returns WHERE clauses.
        at         line 339
                            array
    getJoins()
        
    
    Returns JOIN clauses.
        at         line 349
                            array
    getGroupings()
        
    
    Returns GROUP BY clauses.
        at         line 359
                            array
    getHavings()
        
    
    Returns HAVING clauses.
        at         line 369
                            array
    getOrderings()
        
    
    Returns ORDER BY clauses.
        at         line 379
                            int|null
    getLimit()
        
    
    Returns the limit.
        at         line 389
                            int|null
    getOffset()
        
    
    Returns the offset.
        at         line 399
                            bool|string|null
    getLock()
        
    
    Returns the lock.
        at         line 409
                            string|null
    getPrefix()
        
    
    Returns the prefix.
        at         line 421
                            $this
    forCompiler(string $compilerClass, Closure $query)
        
    
    Executes the closure if the compiler is of the correct class.
        at         line 439
                            $this
    with(string $name, array $columns, Subquery $query)
        
    
    Adds a common table expression.
        at         line 459
                            $this
    withRecursive(string $name, array $columns, Subquery $query)
        
    
    Adds a recursive common table expression.
        at         line 472
                    protected        $this
    setOperation(string $operation)
        
    
    Adds a set operation.
        at         line 492
                            $this
    union()
        
    
    Adds a UNION operation.
        at         line 502
                            $this
    unionAll()
        
    
    Adds a UNION ALL operation.
        at         line 512
                            $this
    intersect()
        
    
    Adds a INTERSECT operation.
        at         line 522
                            $this
    intersectAll()
        
    
    Adds a INTERSECT ALL operation.
        at         line 532
                            $this
    except()
        
    
    Adds a EXCEPT operation.
        at         line 542
                            $this
    exceptAll()
        
    
    Adds a EXCEPT ALL operation.
        at         line 588
                            $this
    select(array $columns)
        
    
    Sets the columns we want to select.
        at         line 602
                            $this
    selectRaw(string $sql, array $parameters = [])
        
    
    Sets the columns we want to select using raw SQL.
        at         line 614
                            $this
    distinct()
        
    
    Select distinct?
        at         line 630
                            $this
    where(string|array|Closure $column, string|null $operator = null, mixed $value = null, string $separator = 'AND')
        
    
    Adds a WHERE clause.
        at         line 669
                            $this
    whereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null, string $separator = 'AND')
        
    
    Adds a raw WHERE clause.
        at         line 694
                            $this
    orWhere(string|array|Closure $column, string|null $operator = null, mixed $value = null)
        
    
    Adds a OR WHERE clause.
        at         line 707
                            $this
    orWhereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null)
        
    
    Adds a raw OR WHERE clause.
        at         line 721
                            $this
    whereDate(string $column, string $operator, string|DateTimeInterface $date, string $separator = 'AND')
        
    
    Adds a date comparison clause.
        at         line 744
                            $this
    orWhereDate(string $column, string $operator, string|DateTimeInterface $date)
        
    
    Adds a date comparison clause.
        at         line 758
                            $this
    whereColumn(string|array $column1, string $operator, string|array $column2, string $separator = 'AND')
        
    
    Adds a column comparison clause.
        at         line 780
                            $this
    orWhereColumn(string|array $column1, string $operator, string|array $column2)
        
    
    Adds a column comparison clause.
        at         line 795
                            $this
    between(mixed $column, mixed $value1, mixed $value2, string $separator = 'AND', bool $not = false)
        
    
    Adds a BETWEEN clause.
        at         line 818
                            $this
    orBetween(mixed $column, mixed $value1, mixed $value2)
        
    
    Adds a OR BETWEEN clause.
        at         line 831
                            $this
    notBetween(mixed $column, mixed $value1, mixed $value2)
        
    
    Adds a NOT BETWEEN clause.
        at         line 844
                            $this
    orNotBetween(mixed $column, mixed $value1, mixed $value2)
        
    
    Adds a OR NOT BETWEEN clause.
        at         line 859
                            $this
    betweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2, string $separator = 'AND', bool $not = false)
        
    
    Adds a date range clause.
        at         line 881
                            
    orBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)
        
    
    Adds a date range clause.
        at         line 893
                            
    notBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)
        
    
    Adds a date range clause.
        at         line 905
                            
    orNotBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)
        
    
    Adds a date range clause.
        at         line 919
                            $this
    in(mixed $column, array|Raw|Subquery $values, string $separator = 'AND', bool $not = false)
        
    
    Adds a IN clause.
        at         line 977
                            $this
    isNull(mixed $column, string $separator = 'AND', bool $not = false)
        
    
    Adds a IS NULL clause.
        at         line 996
                            $this
    orIsNull(mixed $column)
        
    
    Adds a OR IS NULL clause.
        at         line 1007
                            $this
    isNotNull(mixed $column)
        
    
    Adds a IS NOT NULL clause.
        at         line 1018
                            $this
    orIsNotNull(mixed $column)
        
    
    Adds a OR IS NOT NULL clause.
        at         line 1031
                            $this
    exists(Subquery $query, string $separator = 'AND', bool $not = false)
        
    
    Adds a EXISTS clause.
        at         line 1050
                            $this
    orExists(Subquery $query)
        
    
    Adds a OR EXISTS clause.
        at         line 1061
                            $this
    notExists(Subquery $query)
        
    
    Adds a NOT EXISTS clause.
        at         line 1072
                            $this
    orNotExists(Subquery $query)
        
    
    Adds a OR NOT EXISTS clause.
        at         line 1088
                            $this
    join(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null, string $type = 'INNER', bool $raw = false)
        
    
    Adds a JOIN clause.
        at         line 1123
                            $this
    joinRaw(string $table, string $column1, string $operator, string $raw, string $type = 'INNER')
        
    
    Adds a raw JOIN clause.
        at         line 1137
                            $this
    leftJoin(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null)
        
    
    Adds a LEFT OUTER JOIN clause.
        at         line 1151
                            $this
    leftJoinRaw(string $table, string $column1, string $operator, string $raw)
        
    
    Adds a raw LEFT OUTER JOIN clause.
        at         line 1162
                            $this
    groupBy(string|array $columns)
        
    
    Adds a GROUP BY clause.
        at         line 1178
                            $this
    having(string $column, string $operator, mixed $value, string $separator = 'AND')
        
    
    Adds a HAVING clause.
        at         line 1200
                            $this
    havingRaw(string $raw, string $operator, mixed $value, string $separator = 'AND')
        
    
    Adds a raw HAVING clause.
        at         line 1213
                            $this
    orHaving(string $column, string $operator, mixed $value)
        
    
    Adds a OR HAVING clause.
        at         line 1226
                            $this
    orHavingRaw(string $raw, string $operator, mixed $value)
        
    
    Adds a raw OR HAVING clause.
        at         line 1238
                            $this
    orderBy(string|array $columns, string $order = 'ASC')
        
    
    Adds a ORDER BY clause.
        at         line 1257
                            $this
    orderByRaw(string $raw, array $parameters = [], string $order = 'ASC')
        
    
    Adds a raw ORDER BY clause.
        at         line 1268
                            $this
    ascending(string|array $columns)
        
    
    Adds an ascending ORDER BY clause.
        at         line 1280
                            $this
    ascendingRaw(string $raw, array $parameters = [])
        
    
    Adds a raw ascending ORDER BY clause.
        at         line 1291
                            $this
    descending(string|array $columns)
        
    
    Adds a descending ORDER BY clause.
        at         line 1303
                            $this
    descendingRaw(string $raw, array $parameters = [])
        
    
    Adds a raw descending ORDER BY clause.
        at         line 1313
                            $this
    clearOrderings()
        
    
    Clears the ordering clauses.
        at         line 1326
                            $this
    limit(int $limit)
        
    
    Adds a LIMIT clause.
        at         line 1339
                            $this
    offset(int $offset)
        
    
    Adds a OFFSET clause.
        at         line 1352
                            $this
    lock(bool|string $lock = true)
        
    
    Enable lock.
        at         line 1364
                            $this
    sharedLock()
        
    
    Enable shared lock.
        at         line 1375
                            $this
    prefix(string $prefix)
        
    
    Adds a query prefix.
        at         line 1388
                    protected        mixed
    fetchFirst(mixed ...$fetchMode)
        
    
    Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.
        at         line 1400
                            mixed
    first()
        
    
    Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.
        at         line 1411
                    protected        ResultSet
    createResultSet(array $results)
        
    
    Creates a result set.
        at         line 1423
                    protected        array|ResultSet
    fetchAll(bool $returnResultSet, mixed ...$fetchMode)
        
    
    Executes a SELECT query and returns an array containing all of the result set rows.
        at         line 1437
                            ResultSet
    all()
        
    
    Executes a SELECT query and returns an array containing all of the result set rows.
        at         line 1448
                            mixed
    column(string $column = null)
        
    
    Executes a SELECT query and returns the value of the chosen column of the first row of the result set.
        at         line 1466
                            array
    columns(string $column = null)
        
    
    Executes a SELECT query and returns an array containing the values of the indicated 0-indexed column.
        at         line 1485
                            array
    pairs(string $key, string $value)
        
    
    Executes a SELECT query and returns an array where the first column is used as keys and the second as values.
        at         line 1500
                    protected        Generator
    fetchYield(mixed ...$fetchMode)
        
    
    Executes a SELECT query and returns a generator that lets you iterate over the results.
        at         line 1512
                            Generator
    yield()
        
    
    Executes a SELECT query and returns a generator that lets you iterate over the results.
        at         line 1522
                    protected        int
    paginationCount()
        
    
    Returns the number of records that the query will return.
        at         line 1544
                            ResultSet
    paginate(int|null $itemsPerPage = null, array $options = [])
        
    
    Paginates the results using a pagination instance.
        at         line 1572
                            
    batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, int|null $offsetEnd = null)
        
    
    Fetches data in batches and passes them to the processor closure.
        at         line 1613
                    protected        mixed
    aggregate(string $function, string|array $column)
        
    
    Sets the selected column of the query to the chosen aggreate.
Executes the query and returns the result if not in subquery context.
        at         line 1631
                            mixed
    min(string $column)
        
    
    Returns the minimum value for the chosen column.
        at         line 1642
                            mixed
    max(string $column)
        
    
    Returns the maximum value for the chosen column.
        at         line 1653
                            mixed
    sum(string $column)
        
    
    Returns sum of all the values in the chosen column.
        at         line 1664
                            mixed
    avg(string $column)
        
    
    Returns the average value for the chosen column.
        at         line 1675
                            int
    count(string $column = '*')
        
    
    Returns the number of rows.
        at         line 1686
                            int
    countDistinct(string|array $column)
        
    
    Returns the number of distinct values of the chosen column.
        at         line 1697
                            bool
    insert(array $values = [])
        
    
    Inserts data into the chosen table.
        at         line 1711
                            int|false
    insertAndGetId(array $values, string $primaryKey = 'id')
        
    
    Inserts data into the chosen table and returns the auto increment id.
        at         line 1722
                            int
    update(array $values)
        
    
    Updates data from the chosen table.
        at         line 1736
                            int
    increment(string $column, int $increment = 1)
        
    
    Increments column value.
        at         line 1748
                            int
    decrement(string $column, int $decrement = 1)
        
    
    Decrements column value.
        at         line 1758
                            int
    delete()
        
    
    Deletes data from the chosen table.