\Charcoal\SourceStorableTrait

Full implementation, as trait, of the StorableInterface

Summary

Methods
Properties
Constants
setId()
id()
setKey()
key()
setSource()
source()
load()
loadFrom()
loadFromQuery()
save()
update()
delete()
No public properties found
No constants found
setSourceFactory()
sourceFactory()
createSource()
preSave()
postSave()
preUpdate()
postUpdate()
preDelete()
postDelete()
$id
$key
$sourceFactory
N/A
No private methods found
$source
N/A

Properties

$id

$id : mixed

Type

mixed — The object (unique) identifier

$key

$key : string

Type

string — The object key

$sourceFactory

$sourceFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

setId()

setId(mixed  $id) : \Charcoal\Source\StorableInterface

Set the object's ID. The actual property set depends on `key()`

Parameters

mixed $id

The object id (identifier / primary key value).

Throws

\InvalidArgumentException

If the argument is not scalar.

Returns

\Charcoal\Source\StorableInterface

Chainable

id()

id() : mixed

Get the object's (unique) ID. The actualy property get depends on `key()`

Throws

\Exception

If the set key is invalid.

Returns

mixed

setKey()

setKey(string  $key) : \Charcoal\Source\StorableInterface

Set the key property.

Parameters

string $key

The object key, or identifier "name".

Throws

\InvalidArgumentException

If the argument is not scalar.

Returns

\Charcoal\Source\StorableInterface

Chainable

key()

key() : string

Get the key property.

Returns

string

load()

load(mixed  $id = null) : \Charcoal\Source\StorableInterface

Load an object from the database from its ID.

Parameters

mixed $id

The identifier to load.

Returns

\Charcoal\Source\StorableInterface

Chainable

loadFrom()

loadFrom(string  $key = null, mixed  $value = null) : \Charcoal\Source\StorableInterface

Load an object from the database from its key $key.

Parameters

string $key

Key pointing a column's name.

mixed $value

Value of said column.

Returns

\Charcoal\Source\StorableInterface

Chainable.

loadFromQuery()

loadFromQuery(string  $query, array  $binds = array()) : \Charcoal\Source\StorableInterface

Load an object from the database from a custom SQL query.

Parameters

string $query

The SQL query.

array $binds

Optional. The SQL query parameters.

Returns

\Charcoal\Source\StorableInterface

Chainable.

save()

save() : boolean

Save an object current state to storage

Returns

boolean

update()

update(array  $properties = null) : boolean

Update the object in storage to the current object state.

Parameters

array $properties

If set, only update the properties specified in this array.

Returns

boolean

delete()

delete() : boolean

Delete an object from storage.

Returns

boolean

setSourceFactory()

setSourceFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Source\StorableInterface

Parameters

\Charcoal\Factory\FactoryInterface $factory

The source factory, which is useful to create source.

Returns

\Charcoal\Source\StorableInterface

Chainable

sourceFactory()

sourceFactory() : \Charcoal\Factory\FactoryInterface

Throws

\Exception

If the source factory was not previously set.

Returns

\Charcoal\Factory\FactoryInterface

preSave()

preSave() : boolean

Returns

boolean

postSave()

postSave() : boolean

Returns

boolean

preUpdate()

preUpdate(array<mixed,string>  $keys = null) : boolean

Parameters

array<mixed,string> $keys

Optional. The list of keys to update.

Returns

boolean

postUpdate()

postUpdate(array<mixed,string>  $keys = null) : boolean

Parameters

array<mixed,string> $keys

Optional. The list of keys to update.

Returns

boolean

preDelete()

preDelete() : boolean

Returns

boolean

postDelete()

postDelete() : boolean

Returns

boolean