class Builder extends Builder

Adapted from october\rain\database\QueryBuilder

Properties

protected string $cacheKey

The key that should be used when caching the query.

protected int $cacheMinutes

The number of minutes to cache the query.

protected array $cacheTags

The tags for the query cache.

protected bool $cachingDuplicateQueries

Indicates whether duplicate queries are being cached in memory.

array $concats

The aliased concatenation columns.

Methods

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

Get an array with the values of a given column.

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

Indicate that the query results should be cached.

Builder|Builder
rememberForever(string $key = null)

Indicate that the query results should be cached forever.

$this
cacheTags(array|mixed $cacheTags)

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

get($columns = ['*'])

No description

array
getDuplicateCached(array $columns = ['*'])

Check the memory cache before executing the query

array
getCached(array $columns = ['*'])

Execute the query as a cached "select" statement.

CacheManager
getCache()

Get the cache object with tags assigned, if applicable.

array
getCacheInfo()

Get the cache key and cache minutes as an array.

string
getCacheKey()

Get a unique cache key for the complete query.

string
generateCacheKey()

Generate the unique cache key for the query.

getCacheCallback(array $columns)

Get the Closure callback used when caching queries.

int
count(string $columns = '*')

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

int
update(array $values)

Update a record in the database.

int
delete(mixed $id = null)

Delete a record from the database.

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

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

bool
insert(array $values)

Insert a new record into the database.

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

Insert new records or update the existing ones.

void
truncate()

Run a truncate statement on the table.

Builder|Builder
clearDuplicateCache(string|null $table = null)

Clear memory cache for the given table.

Builder|Builder
flushDuplicateCache()

Flush the memory cache.

Builder|Builder
enableDuplicateCache()

Enable the memory cache on the query.

Builder|Builder
disableDuplicateCache()

Disable the memory cache on the query.

bool
cachingDuplicates()

Determine whether we're caching duplicate queries.

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

Adds a concatenated column as an alias.

Details

at line 57
array lists(string $column, string|null $key = null)

Get an array with the values of a given column.

Parameters

string $column
string|null $key

Return Value

array

at line 69
$this remember(DateTime|int $minutes, string $key = null)

Indicate that the query results should be cached.

Parameters

DateTime|int $minutes
string $key

Return Value

$this

at line 83
Builder|Builder rememberForever(string $key = null)

Indicate that the query results should be cached forever.

Parameters

string $key

Return Value

Builder|Builder

at line 94
$this cacheTags(array|mixed $cacheTags)

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

Parameters

array|mixed $cacheTags

Return Value

$this

at line 104
get($columns = ['*'])

No description

Parameters

$columns

at line 123
protected array getDuplicateCached(array $columns = ['*'])

Check the memory cache before executing the query

Parameters

array $columns

Return Value

array

at line 151
array getCached(array $columns = ['*'])

Execute the query as a cached "select" statement.

Parameters

array $columns

Return Value

array

at line 190
protected CacheManager getCache()

Get the cache object with tags assigned, if applicable.

Return Value

CacheManager

at line 202
protected array getCacheInfo()

Get the cache key and cache minutes as an array.

Return Value

array

at line 212
string getCacheKey()

Get a unique cache key for the complete query.

Return Value

string

at line 222
string generateCacheKey()

Generate the unique cache key for the query.

Return Value

string

at line 235
protected Closure getCacheCallback(array $columns)

Get the Closure callback used when caching queries.

Parameters

array $columns

Return Value

Closure

at line 249
int count(string $columns = '*')

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

Parameters

string $columns

Return Value

int

at line 268
int update(array $values)

Update a record in the database.

Parameters

array $values

Return Value

int

at line 281
int delete(mixed $id = null)

Delete a record from the database.

Parameters

mixed $id

Return Value

int

at line 295
int insertGetId(array $values, string $sequence = null)

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

Parameters

array $values
string $sequence

Return Value

int

at line 308
bool insert(array $values)

Insert a new record into the database.

Parameters

array $values

Return Value

bool

at line 323
int upsert(array $values, array|string $uniqueBy, array|null $update = null)

Insert new records or update the existing ones.

Parameters

array $values
array|string $uniqueBy
array|null $update

Return Value

int

at line 366
void truncate()

Run a truncate statement on the table.

Return Value

void

at line 379
Builder|Builder clearDuplicateCache(string|null $table = null)

Clear memory cache for the given table.

Parameters

string|null $table

Return Value

Builder|Builder

at line 391
Builder|Builder flushDuplicateCache()

Flush the memory cache.

Return Value

Builder|Builder

at line 403
Builder|Builder enableDuplicateCache()

Enable the memory cache on the query.

Return Value

Builder|Builder

at line 415
Builder|Builder disableDuplicateCache()

Disable the memory cache on the query.

Return Value

Builder|Builder

at line 427
bool cachingDuplicates()

Determine whether we're caching duplicate queries.

Return Value

bool

at line 439
$this selectConcat(array $parts, string $as)

Adds a concatenated column as an alias.

Parameters

array $parts

The concatenation parts.

string $as

The name of the alias for the compiled concatenation.

Return Value

$this