October\Rain\Halcyon\Builder

Source: ~/vendor/october/rain/src/Halcyon/Builder.php

Query builder

Public properties

public array $columns

The columns that should be returned.

public array $extensions

Filter the query by these file extensions.

public string $from

The directory name which the query is targeting.

public bool $selectSingle

Query should pluck a single record.

public string $fileMatch

Match files using the specified pattern.

public array $orders

The orderings for the query.

public int $limit

The maximum number of records to return.

public int $offset

The number of records to skip.

Protected properties

protected October\Rain\Halcyon\Datasource\DatasourceInterface $datasource

The datasource instance.

protected October\Rain\Halcyon\Model $model

The model being queried.

protected October\Rain\Halcyon\Processors\Processor $processor

The datasource query post processor instance.

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 string $cacheDriver

The cache driver to be used.

protected bool $loadedFromCache

Internal variable to specify if the record was loaded from cache.

Public methods

public mixed __call(string $method, array $parameters)

Handle dynamic method calls into the method.

Parameters
  • string $method
  • array $parameters

public void __construct(October\Rain\Halcyon\Datasource\DatasourceInterface $datasource, October\Rain\Halcyon\Processors\Processor $processor)

Create a new query builder instance.

Parameters

public $this cacheDriver(string $cacheDriver)

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

Parameters
  • string $cacheDriver

public $this cacheTags(array|mixed $cacheTags)

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

Parameters
  • array|mixed $cacheTags

public static void clearInternalCache()

Clears the internal request-level object cache.

public int delete(string $fileName=NULL)

Delete a record from the database.

Parameters
  • string $fileName

public mixed|static find(string $fileName)

Find a single template by its file name.

Parameters
  • string $fileName

public mixed|static first()

Execute the query and get the first result.

public $this from(string $dirName)

Set the directory name which the query is targeting.

Parameters
  • string $dirName

public string generateCacheKey()

Generate the unique cache key for the query.

public October\Rain\Halcyon\Collection|static[] get(array $columns=array( 0=>'*'))

Execute the query as a "select" statement.

Parameters
  • array $columns

public string getCacheKey()

Get a unique cache key for the complete query.

public array getCached(array $columns=array( 0=>'*'))

Execute the query as a cached "select" statement.

Parameters
  • array $columns

public October\Rain\Halcyon\Collection|static[] getFresh(array $columns=array( 0=>'*'))

Execute the query as a fresh "select" statement.

Parameters
  • array $columns

public October\Rain\Halcyon\Model getModel()

Get the model instance being queried.

public October\Rain\Halcyon\Model[] getModels(array $results)

Get the hydrated models.

Parameters
  • array $results

public bool insert(array $values)

Insert a new record into the datasource.

Parameters
  • array $values

public int lastModified()

Returns the last modified time of the object.

public $this limit(int $value)

Set the "limit" value of the query.

Parameters
  • int $value

public array lists(string $column, string $key=NULL)

Get an array with the values of a given column.

Parameters
  • string $column
  • string $key

public $this offset(int $value)

Set the "offset" value of the query.

Parameters
  • int $value

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

Indicate that the query results should be cached.

Parameters
  • DateTime|int $minutes
  • string $key

public $this rememberForever(string $key=NULL)

Indicate that the query results should be cached forever.

Parameters
  • string $key

public $this setModel(October\Rain\Halcyon\Model $model)

Set a model instance for the model being queried.

Parameters

public October\Rain\Halcyon\Builder|static skip(int $value)

Alias to set the "offset" value of the query.

Parameters
  • int $value

public October\Rain\Halcyon\Builder|static take(int $value)

Alias to set the "limit" value of the query.

Parameters
  • int $value

public string toCompiled()

Get the compiled file content representation of the query.

public int update(array $values)

Update a record in the datasource.

Parameters
  • array $values

public $this whereFileName(string $fileName)

Switches mode to select a single template by its name.

Parameters
  • string $fileName

Protected methods

protected Illuminate\Cache\CacheManager getCache()

Get the cache object with tags assigned, if applicable.

protected Closure getCacheCallback(string $fileName)

Get the Closure callback used when caching queries.

Parameters
  • string $fileName

protected bool isCacheBusted(array $result)

Returns true if the cache for the file is busted. This only applies to single record selection.

Parameters
  • array $result

protected array processInitCacheData(array $data)

Initialize the cache data of each record.

Parameters
  • array $data

protected array runSelect()

Run the query as a "select" statement against the datasource.

protected void validateFileName(string $fileName=NULL)

Validate the supplied filename, extension and path.

Parameters
  • string $fileName

protected void validateFileNameExtension(string $fileName, array $allowedExtensions)

Validates whether a file has an allowed extension.

Parameters
  • string $fileName - Specifies a path to validate
  • array $allowedExtensions - A list of allowed file extensions

protected void validateFileNamePath(string $filePath, integer $maxNesting=2)

Validates a template path. Template directory and file names can contain only alphanumeric symbols, dashes and dots.

Parameters
  • string $filePath - Specifies a path to validate
  • integer $maxNesting - Specifies the maximum allowed nesting level

protected boolean validateFileNamePattern(string $fileName)

Validates a template file or directory name. template file names can contain only alphanumeric symbols, dashes, underscores and dots.

Parameters
  • string $fileName - Specifies a path to validate