QueryBuilder

 class Winter\Storm\Database\QueryBuilder
extends Illuminate\Database\Query\Builder

Properties

public $concats : array

The aliased concatenation columns.

protected $cacheKey : string

The key that should be used when caching the query.

protected $cacheMinutes : int | null

The number of minutes to cache the query.

protected $cacheTags : array

The tags for the query cache.

protected $cachingDuplicateQueries : bool

Indicates whether duplicate queries are being cached in memory.

Methods

public cacheTags (array | mixed $cacheTags) : $this

Indicate that the results, if cached, should use the given cache tags.

Parameters
Property Description
$cacheTags
array | mixed
Returns
$this

public cachingDuplicates () : bool

Determine whether we're caching duplicate queries.

Returns
bool

public clearDuplicateCache (string | null $table = null) : Illuminate\Database\Query\Builder | static

Clear memory cache for the given table.

Parameters
Property Description
$table
string | null
Returns
Illuminate\Database\Query\Builder | static

public count (string $columns = "*") : integer

Retrieve the "count" result of the query, also strips off any orderBy clause.

Parameters
Property Description
$columns
string
Returns
integer

public delete (mixed $id = null) : int

Delete a record from the database.

Parameters
Property Description
$id
mixed
Returns
int

public disableDuplicateCache () : static

Disable the memory cache on the query.

Returns
static

public enableDuplicateCache () : static

Enable the memory cache on the query.

Returns
static

public flushDuplicateCache () : Illuminate\Database\Query\Builder | static

Flush the memory cache.

Returns
Illuminate\Database\Query\Builder | static

public generateCacheKey () : string

Generate the unique cache key for the query.

Returns
string

public get (array $columns = ["*"])

Parameters
Property Description
$columns
array
Returns
mixed

public getCacheKey () : string

Get a unique cache key for the complete query.

Returns
string

public getCached (array $columns = ["*"]) : BaseCollection

Execute the query as a cached "select" statement.

Parameters
Property Description
$columns
array
Returns
BaseCollection

public getCountForPagination (array $columns = ["*"]) : int

Get the count of the total records for the paginator.

Parameters
Property Description
$columns
array
Returns
int

public insert (array $values) : bool

Insert a new record into the database.

Parameters
Property Description
$values
array
Returns
bool

public insertGetId (array $values, string $sequence = null) : int

Insert a new record and get the value of the primary key.

Parameters
Property Description
$values
array
$sequence
string
Returns
int

public lists (string $column, string | null $key = null) : array

Get an array with the values of a given column.

Parameters
Property Description
$column
string
$key
string | null
Returns
array

public remember (DateTime | int $minutes, string $key = null) : $this

Indicate that the query results should be cached.

Parameters
Property Description
$minutes
DateTime | int
$key
string
Returns
$this

public rememberForever (string $key = null) : Illuminate\Database\Query\Builder | static

Indicate that the query results should be cached forever.

Parameters
Property Description
$key
string
Returns
Illuminate\Database\Query\Builder | static

public selectConcat (array $parts, string $as) : $this

Adds a concatenated column as an alias.

Parameters
Property Description
$parts
array

The concatenation parts.

$as
string

The name of the alias for the compiled concatenation.

Returns
$this

public truncate () : void

Run a truncate statement on the table.

Returns
void

public update (array $values) : int

Update a record in the database.

Parameters
Property Description
$values
array
Returns
int

public upsert (array $values, array | string $uniqueBy, array | null $update = null) : int

Insert new records or update the existing ones.

Parameters
Property Description
$values
array
$uniqueBy
array | string
$update
array | null
Returns
int

protected cloneForPaginationCount () : self

Clone the existing query instance for usage in a pagination subquery.

Returns
self

protected getCache () : Illuminate\Cache\CacheManager

Get the cache object with tags assigned, if applicable.

Returns
Illuminate\Cache\CacheManager

protected getCacheCallback (array $columns) : Closure

Get the Closure callback used when caching queries.

Parameters
Property Description
$columns
array
Returns
Closure

protected getCacheInfo () : array

Get the cache key and cache minutes as an array.

Returns
array

protected getDuplicateCached (array $columns = ["*"]) : BaseCollection

Check the memory cache before executing the query

Parameters
Property Description
$columns
array
Returns
BaseCollection

protected runPaginationCountQuery (array $columns = ["*"]) : array

Run a pagination count query.

Parameters
Property Description
$columns
array
Returns
array
Copyright © 2024 Winter CMS