October\Rain\Halcyon\Datasource\DbDatasource

Source: ~/vendor/october/rain/src/Halcyon/Datasource/DbDatasource.php

Extends:

Implements:

Database based data source

Table Structure:

  • id, unsigned integer
  • source, varchar
  • path, varchar
  • content, longText
  • file_size, unsigned integer // In bytes - NOTE: max file size of 4.29 GB represented with unsigned int in MySQL
  • updated_at, datetime
  • deleted_at, datetime, nullable

Protected properties

protected string $source

The identifier for this datasource instance

protected string $table

The table name of the datasource

Show inherited protected properties

Inherited protected properties

Public methods

public void __construct(string $source, string $table)

Create a new datasource instance.

Parameters
  • string $source - The source identifier for this datasource instance
  • string $table - The table for this database datasource

public bool delete(string $dirName, string $fileName, string $extension)

Run a delete statement against the datasource.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public array getAvailablePaths()

Get all available paths within this datastore

public void getBaseQuery()

Get the base QueryBuilder object

public string getPathsCacheKey()

Generate a paths cache key unique to this datasource

public QueryBuilder getQuery(bool $ignoreDeleted=true)

Get the QueryBuilder object

Parameters
  • bool $ignoreDeleted - Flag to ignore deleted records, defaults to true

public bool insert(string $dirName, string $fileName, string $extension, string $content)

Creates a new template.

Parameters
  • string $dirName
  • string $fileName
  • string $extension
  • string $content

public int lastModified(string $dirName, string $fileName, string $extension)

Return the last modified date of an object

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public string makeCacheKey(string $name='')

Generate a cache key unique to this datasource.

Parameters
  • string $name

public array select(string $dirName, array $options=array())

Returns all templates.

Parameters
  • string $dirName
  • array $options - Array of options, [ 'columns' => ['fileName', 'mtime', 'content'], // Only return specific columns 'extensions' => ['htm', 'md', 'twig'], // Extensions to search for 'fileMatch' => '*gr[ae]y', // Shell matching pattern to match the filename against using the fnmatch function 'orders' => false // Not implemented 'limit' => false // Not implemented 'offset' => false // Not implemented ];

public mixed selectOne(string $dirName, string $fileName, string $extension)

Returns a single template.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public int update(string $dirName, string $fileName, string $extension, string $content, string $oldFileName=NULL, string $oldExtension=NULL)

Updates an existing template.

Parameters
  • string $dirName
  • string $fileName
  • string $extension
  • string $content
  • string $oldFileName - Defaults to null
  • string $oldExtension - Defaults to null

Show inherited public methods

Inherited public methods

Protected methods

protected string makeFilePath(string $dirName, string $fileName, string $extension)

Helper to make file path.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

Show inherited protected methods

Inherited protected methods