Class ActiveRecord
Active Record facilitates the creation and use of business objects whose data require persistent storage via database.
- ICanBoogie\Prototyped
- ┗ ICanBoogie\ActiveRecord
Methods summary
public
__construct( string|ICanBoogie\ActiveRecord\Model
|null $model
= null )
Initializes the $model and ICanBoogie\ActiveRecord::$model_id
properties.
Initializes the $model and ICanBoogie\ActiveRecord::$model_id
properties.
Parameters
$model
The model managing the active record. A
ICanBoogie\ActiveRecord\Model
instance can be specified as well as a model identifier. If a model identifier is specified, the model is resolved when the $model property is accessed. If$model
is empty, the identifier of the model is read from theICanBoogie\ActiveRecord::MODEL_ID
class constant.
Throws
if $model is neither a model identifier nor a
ICanBoogie\ActiveRecord\Model
instance.
public
__sleep( void )
Removes the $model property.
Removes the $model property.
Properties whose value are instances of the ICanBoogie\ActiveRecord
class are removed from the
exported properties.
public
__debugInfo( void )
: array
Removes model
from the output, since model_id
is good enough to figure which model
is used.
Removes model
from the output, since model_id
is good enough to figure which model
is used.
Returns
protected
get_model( void )
: ICanBoogie\ActiveRecord\Model
Returns the model managing the active record.
protected
get_model_id( void )
: string
Returns the identifier of the model managing the active record.
Returns the identifier of the model managing the active record.
Returns
public
save( void )
: integer|boolean
Saves the active record using its model.
Saves the active record using its model.
Returns
Primary key value of the active record, or a boolean if the primary key is not a serial.
protected
alter_persistent_properties( array $properties
, ICanBoogie\ActiveRecord\Model
$model
)
: array
Unless it's an acceptable value for a column, columns with null
values are discarded.
This way, we don't have to define every properties before saving our active record.
Unless it's an acceptable value for a column, columns with null
values are discarded.
This way, we don't have to define every properties before saving our active record.
Parameters
$properties
$model
Returns
The altered persistent properties