Class Model
Base class for activerecord models.
ICanBoogie\Object
┗
ICanBoogie\ActiveRecord\Table
┗
ICanBoogie\ActiveRecord\Model
implements
ArrayAccess
Methods summary
protected
get_models ( void )
public
__call ( $method
, $arguments
)
Handles query methods, dynamic filters, scopes, and relations.
Handles query methods, dynamic filters, scopes, and relations.
Inheritdoc
public
__get ( $property
)
Overrides the method to handle scopes.
Overrides the method to handle scopes.
Inheritdoc
protected
get_id ( void )
: string
Returns the identifier of the model.
Returns the identifier of the model.
Returns
string
protected
get_activerecord_class ( void )
: string
Returns the class of the active records of the model.
Returns the class of the active records of the model.
Returns
string
public
find ( mixed $key
)
: ICanBoogie\ActiveRecord
|ICanBoogie\ActiveRecord []
Finds a record or a collection of records.
Finds a record or a collection of records.
Parameters
$key
A key, multiple keys, or an array of keys.
Returns
Throws
public
save ( array $properties
, $key
= null , array $options
= [] )
Because records are cached, we need to remove the record from the cache when it is saved,
so that loading the record again returns the updated record, not the one in the cache.
Because records are cached, we need to remove the record from the cache when it is saved,
so that loading the record again returns the updated record, not the one in the cache.
Inheritdoc
Overrides
public
delete ( mixed $key
)
: boolean
Eliminates the record from the cache.
Eliminates the record from the cache.
Parameters
$key
Identifier of the record.
Returns
boolean
Inheritdoc
Overrides
protected
get_exists ( void )
: boolean
Checks that the SQL table associated with the model exists.
Checks that the SQL table associated with the model exists.
Returns
boolean
protected
get_count ( void )
: integer
Returns the number of records of the model.
Returns the number of records of the model.
Returns
integer
protected
get_all ( void )
: ICanBoogie\ActiveRecord []
Returns all the records of the model.
Returns all the records of the model.
Returns
protected
get_one ( void )
: ICanBoogie\ActiveRecord
Returns the first record of the model.
Returns the first record of the model.
Returns
public
has_scope ( string $name
)
: boolean
Checks if the model has a given scope.
Checks if the model has a given scope.
Scopes are defined using method with the "scope_" prefix. As an example, the visible
scope can be defined by implementing the scope_visible
method.
Parameters
Returns
boolean
public
scope ( string $scope_name
, array $scope_args
= [] )
: ICanBoogie\ActiveRecord\Query
Invokes a given scope.
Parameters
$scope_name
Name of the scope to apply to the query.
$scope_args
Arguments to forward to the scope method. The first argument must
be a ICanBoogie\ActiveRecord\Query
instance.
Returns
Throws
public
offsetSet ( $offset
, $value
)
Throws
ICanBoogie\OffsetNotWritable when one tries to write an offset.
Inheritdoc
Implementation of
ArrayAccess::offsetSet()
public
offsetExists ( integer $key
)
: boolean
Alias to exists().
Parameters
$key
ActiveRecord identifier.
Returns
boolean
Implementation of
ArrayAccess::offsetExists()
public
offsetUnset ( integer $key
)
__invoke()
,
drop()
,
execute()
,
filter_values()
,
get_alias()
,
get_connection()
,
get_name()
,
get_parent()
,
get_primary()
,
get_schema()
,
get_unprefixed_name()
,
insert()
,
install()
,
is_installed()
,
lazy_get_extended_schema()
,
prepare()
,
query()
,
quote()
,
resolve_statement()
,
save_callback()
,
truncate()
,
uninstall()
,
update()
Magic methods summary
public
exists ( void )
: boolean
exists($key=null) The method is forwarded to Query::exists .
Returns
boolean
public
count ( void )
: mixed
count($column=null) The method is forwarded to Query::count .
count($column=null) The method is forwarded to Query::count .
Returns
mixed
public
average ( void )
: string
average($column) The method is forwarded to Query::average .
Returns
string
public
maximum ( void )
: string
maximum($column) The method is forwarded to Query::maximum .
Returns
string
public
minimum ( void )
: string
minimum($column) The method is forwarded to Query::minimum .
Returns
string
public
sum ( void )
: integer
sum($column) The method is forwarded to Query::sum .
sum($column) The method is forwarded to Query::sum .
Returns
integer
public
all ( void )
: array
all() The method is forwarded to Query::all .
Returns
array
public
new ( void )
: ICanBoogie\ActiveRecord
new(array $properties = []) Instantiate a new record.
new(array $properties = []) Instantiate a new record.
Returns
public
belongs_to ( void )
: ICanBoogie\ActiveRecord\Model
belongs_to($definition) Add a belongs_to relation.
belongs_to($definition) Add a belongs_to relation.
Returns
public
has_many ( void )
: ICanBoogie\ActiveRecord\Model
has_many($related, $options=[]) Adds a has_many relation.
has_many($related, $options=[]) Adds a has_many relation.
Returns
Constants summary
ACTIVERECORD_CLASS
: string
'activerecord_class'
BELONGS_TO
: string
'belongs_to'
CLASSNAME
: string
'class'
HAS_MANY
: string
'has_many'
ALIAS
,
CONNECTION
,
EXTENDING
,
IMPLEMENTING
,
NAME
,
SCHEMA
Properties summary
protected
$activerecord_class
: string
Active record instances class.
Active record instances class.
protected
$attributes
: array[string]mixed
$alias
,
$connection
,
$implements
,
$name
,
$parent
,
$primary
,
$schema
,
$select_join
,
$unprefixed_name
,
$update_join
Magic properties
public read-only
$all
: array
Retrieve all the records from the model.
public read-only
$activerecord_class
: string
Class of the active records of the model.
public read-only
$count
: integer
The number of records of the model.
public read-only
$exists
: boolean
Whether the SQL table associated with the model exists.
public read-only
$id
: string
The identifier of the model.
$alias
,
$connection
,
$extended_schema
,
$name
,
$primary
,
$schema
,
$unprefixed_name