DbDatasource
extends Datasource
in package
implements
DatasourceInterface
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
Interfaces, Classes and Traits
Table of Contents
- $emitterEventCollection : array<string|int, mixed>
- $emitterEventSorted : array<string|int, mixed>
- $emitterSingleEventCollection : array<string|int, mixed>
- $forceDeleting : bool
- $postProcessor : Processor
- The query post processor implementation.
- $source : string
- $table : string
- __construct() : void
- Create a new datasource instance.
- bindEvent() : self
- Create a new event binding.
- bindEventOnce() : self
- Create a new event binding that fires once only
- delete() : bool
- Run a delete statement against the datasource.
- fireEvent() : array<string|int, mixed>
- Fire an event and call the listeners.
- forceDelete() : void
- Force the deletion of a record against the datasource
- getAvailablePaths() : array<string|int, mixed>
- Get all available paths within this datastore
- getBaseQuery() : mixed
- Get the base QueryBuilder object
- getPathsCacheKey() : string
- Generate a paths cache key unique to this datasource
- getPostProcessor() : Processor
- Get the query post processor used by the connection.
- getQuery() : QueryBuilder
- Get the QueryBuilder object
- insert() : bool
- Creates a new template.
- lastModified() : int
- Return the last modified date of an object
- makeCacheKey() : string
- Generate a cache key unique to this datasource.
- select() : array<string|int, mixed>
- Returns all templates.
- selectOne() : mixed
- Returns a single template.
- unbindEvent() : self
- Destroys an event binding.
- update() : int
- Updates an existing template.
- emitterEventSortEvents() : array<string|int, mixed>
- Sort the listeners for a given event by priority.
- makeFilePath() : string
- Helper to make file path.
Properties
$emitterEventCollection
protected
array<string|int, mixed>
$emitterEventCollection
= []
Collection of registered events.
$emitterEventSorted
protected
array<string|int, mixed>
$emitterEventSorted
= []
Sorted collection of events.
$emitterSingleEventCollection
protected
array<string|int, mixed>
$emitterSingleEventCollection
= []
Collection of registered events to be fired once only.
$forceDeleting
protected
bool
$forceDeleting
= false
Indicates if the record is currently being force deleted.
$postProcessor
The query post processor implementation.
protected
Processor
$postProcessor
$source
protected
string
$source
The identifier for this datasource instance
$table
protected
string
$table
The table name of the datasource
Methods
__construct()
Create a new datasource instance.
public
__construct(string $source, string $table) : void
Parameters
- $source : string
-
The source identifier for this datasource instance
- $table : string
-
The table for this database datasource
Return values
void —bindEvent()
Create a new event binding.
public
bindEvent(mixed $event, mixed $callback, mixed $priority) : self
Parameters
- $event : mixed
- $callback : mixed
- $priority : mixed
Return values
self —bindEventOnce()
Create a new event binding that fires once only
public
bindEventOnce(mixed $event, mixed $callback) : self
Parameters
- $event : mixed
- $callback : mixed
Return values
self —delete()
Run a delete statement against the datasource.
public
delete(string $dirName, string $fileName, string $extension) : bool
Parameters
- $dirName : string
- $fileName : string
- $extension : string
Return values
bool —fireEvent()
Fire an event and call the listeners.
public
fireEvent(string $event[, array<string|int, mixed> $params = [] ][, bool $halt = false ]) : array<string|int, mixed>
Parameters
- $event : string
-
Event name
- $params : array<string|int, mixed> = []
-
Event parameters
- $halt : bool = false
-
Halt after first non-null result
Return values
array<string|int, mixed> —Collection of event results / Or single result (if halted)
forceDelete()
Force the deletion of a record against the datasource
public
forceDelete(string $dirName, string $fileName, string $extension) : void
Parameters
- $dirName : string
- $fileName : string
- $extension : string
Return values
void —getAvailablePaths()
Get all available paths within this datastore
public
getAvailablePaths() : array<string|int, mixed>
Return values
array<string|int, mixed> —$paths ['path/to/file1.md' => true (path can be handled and exists), 'path/to/file2.md' => false (path can be handled but doesn't exist)]
getBaseQuery()
Get the base QueryBuilder object
public
getBaseQuery() : mixed
Return values
mixed —getPathsCacheKey()
Generate a paths cache key unique to this datasource
public
getPathsCacheKey() : string
Return values
string —getPostProcessor()
Get the query post processor used by the connection.
public
getPostProcessor() : Processor
Return values
Processor —getQuery()
Get the QueryBuilder object
public
getQuery([bool $ignoreDeleted = true ]) : QueryBuilder
Parameters
- $ignoreDeleted : bool = true
-
Flag to ignore deleted records, defaults to true
Return values
QueryBuilder —insert()
Creates a new template.
public
insert(string $dirName, string $fileName, string $extension, string $content) : bool
Parameters
- $dirName : string
- $fileName : string
- $extension : string
- $content : string
Return values
bool —lastModified()
Return the last modified date of an object
public
lastModified(string $dirName, string $fileName, string $extension) : int
Parameters
- $dirName : string
- $fileName : string
- $extension : string
Return values
int —makeCacheKey()
Generate a cache key unique to this datasource.
public
makeCacheKey([string $name = '' ]) : string
Parameters
- $name : string = ''
Return values
string —select()
Returns all templates.
public
select(string $dirName[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $dirName : string
- $options : array<string|int, mixed> = []
-
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 ];
Return values
array<string|int, mixed> —selectOne()
Returns a single template.
public
selectOne(string $dirName, string $fileName, string $extension) : mixed
Parameters
- $dirName : string
- $fileName : string
- $extension : string
Return values
mixed —unbindEvent()
Destroys an event binding.
public
unbindEvent([string $event = null ]) : self
Parameters
- $event : string = null
-
Event to destroy
Return values
self —update()
Updates an existing template.
public
update(string $dirName, string $fileName, string $extension, string $content[, string $oldFileName = null ][, string $oldExtension = null ]) : int
Parameters
- $dirName : string
- $fileName : string
- $extension : string
- $content : string
- $oldFileName : string = null
-
Defaults to null
- $oldExtension : string = null
-
Defaults to null
Return values
int —emitterEventSortEvents()
Sort the listeners for a given event by priority.
protected
emitterEventSortEvents(string $eventName) : array<string|int, mixed>
Parameters
- $eventName : string
Return values
array<string|int, mixed> —makeFilePath()
Helper to make file path.
protected
makeFilePath(string $dirName, string $fileName, string $extension) : string
Parameters
- $dirName : string
- $fileName : string
- $extension : string