Builder
in package
Query builder
Tags
Table of Contents
- $columns : array<string|int, mixed>
- The columns that should be returned.
- $extensions : array<string|int, mixed>
- Filter the query by these file extensions.
- $fileMatch : string
- Match files using the specified pattern.
- $from : string
- The directory name which the query is targeting.
- $limit : int
- The maximum number of records to return.
- $offset : int
- The number of records to skip.
- $orders : array<string|int, mixed>
- The orderings for the query.
- $selectSingle : bool
- Query should pluck a single record.
- $cacheDriver : string
- The cache driver to be used.
- $cacheKey : string
- The key that should be used when caching the query.
- $cacheMinutes : int
- The number of minutes to cache the query.
- $cacheTags : array<string|int, mixed>
- The tags for the query cache.
- $datasource : DatasourceInterface
- The datasource instance.
- $loadedFromCache : bool
- Internal variable to specify if the record was loaded from cache.
- $model : Model
- The model being queried.
- $processor : Processor
- The datasource query post processor instance.
- __call() : void
- Handle dynamic method calls into the method.
- __construct() : void
- Create a new query builder instance.
- cacheDriver() : $this
- Indicate that the results, if cached, should use the given cache driver.
- cacheTags() : $this
- Indicate that the results, if cached, should use the given cache tags.
- clearInternalCache() : mixed
- Clears the internal request-level object cache.
- delete() : int
- Delete a record from the database.
- find() : mixed|static
- Find a single template by its file name.
- first() : mixed|static
- Execute the query and get the first result.
- from() : $this
- Set the directory name which the query is targeting.
- generateCacheKey() : string
- Generate the unique cache key for the query.
- get() : Collection|array<string|int, static>
- Execute the query as a "select" statement.
- getCached() : array<string|int, mixed>
- Execute the query as a cached "select" statement.
- getCacheKey() : string
- Get a unique cache key for the complete query.
- getFresh() : Collection|array<string|int, static>
- Execute the query as a fresh "select" statement.
- getModel() : Model
- Get the model instance being queried.
- getModels() : array<string|int, Model>
- Get the hydrated models.
- insert() : bool
- Insert a new record into the datasource.
- lastModified() : int
- Returns the last modified time of the object.
- limit() : $this
- Set the "limit" value of the query.
- lists() : array<string|int, mixed>
- Get an array with the values of a given column.
- offset() : $this
- Set the "offset" value of the query.
- remember() : $this
- Indicate that the query results should be cached.
- rememberForever() : $this
- Indicate that the query results should be cached forever.
- setModel() : $this
- Set a model instance for the model being queried.
- skip() : Builder|static
- Alias to set the "offset" value of the query.
- take() : Builder|static
- Alias to set the "limit" value of the query.
- toCompiled() : string
- Get the compiled file content representation of the query.
- update() : int
- Update a record in the datasource.
- whereFileName() : $this
- Switches mode to select a single template by its name.
- getCache() : CacheManager
- Get the cache object with tags assigned, if applicable.
- getCacheCallback() : Closure
- Get the Closure callback used when caching queries.
- isCacheBusted() : bool
- Returns true if the cache for the file is busted. This only applies to single record selection.
- processInitCacheData() : array<string|int, mixed>
- Initialize the cache data of each record.
- runSelect() : array<string|int, mixed>
- Run the query as a "select" statement against the datasource.
- validateFileName() : mixed
- Validate the supplied filename, extension and path.
- validateFileNameExtension() : void
- Validates whether a file has an allowed extension.
- validateFileNamePath() : void
- Validates a template path.
- validateFileNamePattern() : bool
- Validates a template file or directory name.
Properties
$columns
The columns that should be returned.
public
array<string|int, mixed>
$columns
$extensions
Filter the query by these file extensions.
public
array<string|int, mixed>
$extensions
$fileMatch
Match files using the specified pattern.
public
string
$fileMatch
$from
The directory name which the query is targeting.
public
string
$from
$limit
The maximum number of records to return.
public
int
$limit
$offset
The number of records to skip.
public
int
$offset
$orders
The orderings for the query.
public
array<string|int, mixed>
$orders
$selectSingle
Query should pluck a single record.
public
bool
$selectSingle
$cacheDriver
The cache driver to be used.
protected
string
$cacheDriver
$cacheKey
The key that should be used when caching the query.
protected
string
$cacheKey
$cacheMinutes
The number of minutes to cache the query.
protected
int
$cacheMinutes
$cacheTags
The tags for the query cache.
protected
array<string|int, mixed>
$cacheTags
$datasource
The datasource instance.
protected
DatasourceInterface
$datasource
$loadedFromCache
Internal variable to specify if the record was loaded from cache.
protected
bool
$loadedFromCache
= false
$model
The model being queried.
protected
Model
$model
$processor
The datasource query post processor instance.
protected
Processor
$processor
Methods
__call()
Handle dynamic method calls into the method.
public
__call(string $method, array<string|int, mixed> $parameters) : void
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
void —__construct()
Create a new query builder instance.
public
__construct(DatasourceInterface $datasource, Processor $processor) : void
Parameters
- $datasource : DatasourceInterface
- $processor : Processor
Return values
void —cacheDriver()
Indicate that the results, if cached, should use the given cache driver.
public
cacheDriver(string $cacheDriver) : $this
Parameters
- $cacheDriver : string
Return values
$this —cacheTags()
Indicate that the results, if cached, should use the given cache tags.
public
cacheTags(array<string|int, mixed>|mixed $cacheTags) : $this
Parameters
- $cacheTags : array<string|int, mixed>|mixed
Return values
$this —clearInternalCache()
Clears the internal request-level object cache.
public
static clearInternalCache() : mixed
Return values
mixed —delete()
Delete a record from the database.
public
delete() : int
Return values
int —find()
Find a single template by its file name.
public
find(string $fileName) : mixed|static
Parameters
- $fileName : string
Return values
mixed|static —first()
Execute the query and get the first result.
public
first() : mixed|static
Return values
mixed|static —from()
Set the directory name which the query is targeting.
public
from(string $dirName) : $this
Parameters
- $dirName : string
Return values
$this —generateCacheKey()
Generate the unique cache key for the query.
public
generateCacheKey() : string
Return values
string —get()
Execute the query as a "select" statement.
public
get([array<string|int, mixed> $columns = ['*'] ]) : Collection|array<string|int, static>
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
Collection|array<string|int, static> —getCached()
Execute the query as a cached "select" statement.
public
getCached([array<string|int, mixed> $columns = ['*'] ]) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
array<string|int, mixed> —getCacheKey()
Get a unique cache key for the complete query.
public
getCacheKey() : string
Return values
string —getFresh()
Execute the query as a fresh "select" statement.
public
getFresh([array<string|int, mixed> $columns = ['*'] ]) : Collection|array<string|int, static>
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
Collection|array<string|int, static> —getModel()
Get the model instance being queried.
public
getModel() : Model
Return values
Model —getModels()
Get the hydrated models.
public
getModels(array<string|int, mixed> $results) : array<string|int, Model>
Parameters
- $results : array<string|int, mixed>
Return values
array<string|int, Model> —insert()
Insert a new record into the datasource.
public
insert(array<string|int, mixed> $values) : bool
Parameters
- $values : array<string|int, mixed>
Return values
bool —lastModified()
Returns the last modified time of the object.
public
lastModified() : int
Return values
int —limit()
Set the "limit" value of the query.
public
limit(int $value) : $this
Parameters
- $value : int
Return values
$this —lists()
Get an array with the values of a given column.
public
lists(string $column[, string $key = null ]) : array<string|int, mixed>
Parameters
- $column : string
- $key : string = null
Return values
array<string|int, mixed> —offset()
Set the "offset" value of the query.
public
offset(int $value) : $this
Parameters
- $value : int
Return values
$this —remember()
Indicate that the query results should be cached.
public
remember(DateTime|int $minutes[, string $key = null ]) : $this
Parameters
- $minutes : DateTime|int
- $key : string = null
Return values
$this —rememberForever()
Indicate that the query results should be cached forever.
public
rememberForever([string $key = null ]) : $this
Parameters
- $key : string = null
Return values
$this —setModel()
Set a model instance for the model being queried.
public
setModel(Model $model) : $this
Parameters
- $model : Model
Return values
$this —skip()
Alias to set the "offset" value of the query.
public
skip(int $value) : Builder|static
Parameters
- $value : int
Return values
Builder|static —take()
Alias to set the "limit" value of the query.
public
take(int $value) : Builder|static
Parameters
- $value : int
Return values
Builder|static —toCompiled()
Get the compiled file content representation of the query.
public
toCompiled() : string
Return values
string —update()
Update a record in the datasource.
public
update(array<string|int, mixed> $values) : int
Parameters
- $values : array<string|int, mixed>
Return values
int —whereFileName()
Switches mode to select a single template by its name.
public
whereFileName(string $fileName) : $this
Parameters
- $fileName : string
Return values
$this —getCache()
Get the cache object with tags assigned, if applicable.
protected
getCache() : CacheManager
Return values
CacheManager —getCacheCallback()
Get the Closure callback used when caching queries.
protected
getCacheCallback(mixed $columns) : Closure
Parameters
- $columns : mixed
Return values
Closure —isCacheBusted()
Returns true if the cache for the file is busted. This only applies to single record selection.
protected
isCacheBusted(array<string|int, mixed> $result) : bool
Parameters
- $result : array<string|int, mixed>
Return values
bool —processInitCacheData()
Initialize the cache data of each record.
protected
processInitCacheData(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
Return values
array<string|int, mixed> —runSelect()
Run the query as a "select" statement against the datasource.
protected
runSelect() : array<string|int, mixed>
Return values
array<string|int, mixed> —validateFileName()
Validate the supplied filename, extension and path.
protected
validateFileName([string $fileName = null ]) : mixed
Parameters
- $fileName : string = null
Return values
mixed —validateFileNameExtension()
Validates whether a file has an allowed extension.
protected
validateFileNameExtension(string $fileName, array<string|int, mixed> $allowedExtensions) : void
Parameters
- $fileName : string
-
Specifies a path to validate
- $allowedExtensions : array<string|int, mixed>
-
A list of allowed file extensions
Return values
void —validateFileNamePath()
Validates a template path.
protected
validateFileNamePath(string $filePath[, int $maxNesting = 2 ]) : void
Template directory and file names can contain only alphanumeric symbols, dashes and dots.
Parameters
- $filePath : string
-
Specifies a path to validate
- $maxNesting : int = 2
-
Specifies the maximum allowed nesting level
Return values
void —validateFileNamePattern()
Validates a template file or directory name.
protected
validateFileNamePattern(string $fileName) : bool
template file names can contain only alphanumeric symbols, dashes, underscores and dots.
Parameters
- $fileName : string
-
Specifies a path to validate
Return values
bool —Returns true if the file name is valid. Otherwise returns false.