ICanBoogie/ActiveRecord master
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • ActiveRecord
      • Driver

Classes

  • ActiveRecordCacheBase
  • BelongsToRelation
  • Connection
  • ConnectionCollection
  • ConnectionOptions
  • DateTimePropertySupport
  • HasManyRelation
  • Helpers
  • Model
  • ModelCollection
  • Query
  • Relation
  • RelationCollection
  • RelationNotDefined
  • RuntimeActiveRecordCache
  • Schema
  • SchemaColumn
  • Statement
  • Table

Interfaces

  • ActiveRecordCache
  • Driver
  • Exception

Traits

  • CreatedAtProperty
  • DateProperty
  • DateTimeProperty
  • FinishAtProperty
  • FinishedAtProperty
  • StartAtProperty
  • StartedAtProperty
  • UpdatedAtProperty

Exceptions

  • ActiveRecordClassNotValid
  • ConnectionAlreadyEstablished
  • ConnectionNotDefined
  • ConnectionNotEstablished
  • DriverNotDefined
  • ModelAlreadyInstantiated
  • ModelNotDefined
  • RecordNotFound
  • ScopeNotDefined
  • StatementInvocationFailed
  • StatementNotValid
  • UnableToSetFetchMode

Functions

  • extract_charset_and_collate
  • get_model

Class Model

Base class for activerecord models.

ICanBoogie\Prototyped
Extended by ICanBoogie\ActiveRecord\Table
Extended by ICanBoogie\ActiveRecord\Model implements ArrayAccess
Namespace: ICanBoogie\ActiveRecord
Located at ActiveRecord/Model.php

Methods summary

protected
# get_models( )
protected ICanBoogie\ActiveRecord\Model
# get_parent_model( )

Return the parent mode.

Return the parent mode.

Returns

ICanBoogie\ActiveRecord\Model
protected ICanBoogie\ActiveRecord\RelationCollection
# get_relations( )

Return the relations of this model to other models.

Return the relations of this model to other models.

Returns

ICanBoogie\ActiveRecord\RelationCollection
protected ICanBoogie\ActiveRecord\ActiveRecordCache
# lazy_get_activerecord_cache( )

Returns the records cache.

Returns the records cache.

Note: The method needs to be implemented through prototype bindings.

Returns

ICanBoogie\ActiveRecord\ActiveRecordCache
public
# __construct( ICanBoogie\ActiveRecord\ModelCollection $models, array $attributes )

Override the constructor to provide support for the ICanBoogie\ActiveRecord\Model::ACTIVERECORD_CLASS tag and extended support for the ICanBoogie\ActiveRecord\Table::EXTENDING tag.

Override the constructor to provide support for the ICanBoogie\ActiveRecord\Model::ACTIVERECORD_CLASS tag and extended support for the ICanBoogie\ActiveRecord\Table::EXTENDING tag.

If ICanBoogie\ActiveRecord\Table::EXTENDING is defined but the model has no schema (ICanBoogie\ActiveRecord\Table::SCHEMA is empty), the name of the model and the schema are inherited from the extended model and ICanBoogie\ActiveRecord\Table::EXTENDING is set to the parent model object. If ICanBoogie\ActiveRecord\Model::ACTIVERECORD_CLASS is empty, its value is set to the extended model's active record class.

If ICanBoogie\ActiveRecord\Model::ACTIVERECORD_CLASS is set, its value is saved in the ICanBoogie\ActiveRecord\Model::$activerecord_class property.

Parameters

$models
$attributes
Attributes used to construct the model.

Throws

InvalidArgumentException
if the ICanBoogie\ActiveRecord\Table::CONNECTION attribute is empty.

Overrides

ICanBoogie\ActiveRecord\Table::__construct
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 string
# get_id( )

Returns the identifier of the model.

Returns the identifier of the model.

Returns

string
protected string
# get_activerecord_class( )

Returns the class of the active records of the model.

Returns the class of the active records of the model.

Returns

string
public ICanBoogie\ActiveRecord|ICanBoogie\ActiveRecord[]
# find( mixed $key )

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

ICanBoogie\ActiveRecord|ICanBoogie\ActiveRecord[]
A record or a set of records.

Throws

ICanBoogie\ActiveRecord\RecordNotFound

when the record, or one or more records of the records set, could not be found.

public mixed
# save( array $properties, mixed|null $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.

Parameters

$properties
$values
$key
$id
$options

Returns

mixed

Throws

Exception

Inheritdoc

Overrides

ICanBoogie\ActiveRecord\Table::save
public boolean
# delete( mixed $key )

Eliminates the record from the cache.

Eliminates the record from the cache.

Parameters

$key
Identifier of the record.

Returns

boolean

Inheritdoc

Overrides

ICanBoogie\ActiveRecord\Table::delete
protected boolean
# get_exists( )

Checks that the SQL table associated with the model exists.

Checks that the SQL table associated with the model exists.

Returns

boolean
protected integer
# get_count( )

Returns the number of records of the model.

Returns the number of records of the model.

Returns

integer
protected ICanBoogie\ActiveRecord[]
# get_all( )

Returns all the records of the model.

Returns all the records of the model.

Returns

ICanBoogie\ActiveRecord[]
protected ICanBoogie\ActiveRecord
# get_one( )

Returns the first record of the model.

Returns the first record of the model.

Returns

ICanBoogie\ActiveRecord
public boolean
# has_scope( string $name )

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

$name
Scope name.

Returns

boolean
public ICanBoogie\ActiveRecord\Query
# scope( string $scope_name, array $scope_args = [] )

Invokes a given scope.

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

ICanBoogie\ActiveRecord\Query

Throws

ICanBoogie\ActiveRecord\ScopeNotDefined
when the specified scope is not defined.
public
# offsetSet( $offset, $value )

Throws

ICanBoogie\OffsetNotWritable
when one tries to write an offset.

Inheritdoc

Implementation of

ArrayAccess::offsetSet()
public boolean
# offsetExists( integer $key )

Alias to exists().

Alias to exists().

Parameters

$key
ActiveRecord identifier.

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public
# offsetUnset( integer $key )

Alias to ICanBoogie\ActiveRecord\Model::delete().

Alias to ICanBoogie\ActiveRecord\Model::delete().

Parameters

$key
ActiveRecord identifier.

Implementation of

ArrayAccess::offsetUnset()
public ICanBoogie\ActiveRecord
# offsetGet( integer $key )

Alias to ICanBoogie\ActiveRecord\Model::find().

Alias to ICanBoogie\ActiveRecord\Model::find().

Parameters

$key
ActiveRecord identifier.

Returns

ICanBoogie\ActiveRecord

Implementation of

ArrayAccess::offsetGet()
protected ICanBoogie\ActiveRecord
# new_record( array $properties = [] )

Creates a new ActiveRecord instance.

Creates a new ActiveRecord instance.

The class of the instance is defined by the ICanBoogie\ActiveRecord\Model::$activerecord_class property.

Parameters

$properties
Optional properties to instantiate the record with.

Returns

ICanBoogie\ActiveRecord

Methods inherited from ICanBoogie\ActiveRecord\Table

__invoke(), assert_has_connection(), assert_has_name(), assert_has_schema(), assert_implements_is_valid(), assert_parent_is_valid(), construct_with_parent(), drop(), ensure_has_alias(), execute(), filter_values(), get_alias(), get_connection(), get_name(), get_parent(), get_primary(), get_schema(), get_schema_options(), get_unprefixed_name(), insert(), install(), is_installed(), lazy_get_extended_schema(), lazy_get_select_join(), lazy_get_update_join(), map_construct_attributes(), prepare(), query(), quote(), resolve_statement(), save_callback(), truncate(), uninstall(), update()

Magic methods summary

public ICanBoogie\ActiveRecord\Query
# select( )

The method is forwarded to Query::select.

The method is forwarded to Query::select.

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# join( )

The method is forwarded to Query::join.

The method is forwarded to Query::join.

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# where( $conditions_args = null, $_ = null )

The method is forwarded to Query::where.

The method is forwarded to Query::where.

Parameters

$conditions_args
$_

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# group( )

The method is forwarded to Query::group.

The method is forwarded to Query::group.

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# order( )

The method is forwarded to Query::order.

The method is forwarded to Query::order.

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# limit( $offset = null )

The method is forwarded to Query::limit.

The method is forwarded to Query::limit.

Parameters

$offset

Returns

ICanBoogie\ActiveRecord\Query
public ICanBoogie\ActiveRecord\Query
# offset( )

The method is forwarded to Query::offset.

The method is forwarded to Query::offset.

Returns

ICanBoogie\ActiveRecord\Query
public boolean
# exists( )

The method is forwarded to Query::exists.

The method is forwarded to Query::exists.

Returns

boolean
public mixed
# count( )

The method is forwarded to Query::count.

The method is forwarded to Query::count.

Returns

mixed
public string
# average( )

The method is forwarded to Query::average.

The method is forwarded to Query::average.

Returns

string
public string
# maximum( )

The method is forwarded to Query::maximum.

The method is forwarded to Query::maximum.

Returns

string
public string
# minimum( )

The method is forwarded to Query::minimum.

The method is forwarded to Query::minimum.

Returns

string
public integer
# sum( )

The method is forwarded to Query::sum.

The method is forwarded to Query::sum.

Returns

integer
public array
# all( )

The method is forwarded to Query::all.

The method is forwarded to Query::all.

Returns

array
public ICanBoogie\ActiveRecord
# one( )

The method is forwarded to Query::one.

The method is forwarded to Query::one.

Returns

ICanBoogie\ActiveRecord
public ICanBoogie\ActiveRecord
# new( )

Instantiate a new record.

Instantiate a new record.

Returns

ICanBoogie\ActiveRecord
public ICanBoogie\ActiveRecord\Model
# belongs_to( )

Add a belongs_to relation.

Add a belongs_to relation.

Returns

ICanBoogie\ActiveRecord\Model
public ICanBoogie\ActiveRecord\Model
# has_many( $options = [] )

Adds a has_many relation.

Adds a has_many relation.

Parameters

$options

Returns

ICanBoogie\ActiveRecord\Model

Constants summary

string ACTIVERECORD_CLASS
# 'activerecord_class'
string BELONGS_TO
# 'belongs_to'
string CLASSNAME
# 'class'
string HAS_MANY
# 'has_many'
string ID
# 'id'

Constants inherited from ICanBoogie\ActiveRecord\Table

ALIAS, CONNECTION, EXTENDING, IMPLEMENTING, NAME, SCHEMA

Properties summary

protected string $activerecord_class

Active record instances class.

Active record instances class.

#
protected array[string]mixed $attributes

Attributes of the model.

Attributes of the model.

#
protected ICanBoogie\ActiveRecord\Model $parent_model

The parent model of the model.

The parent model of the model.

The parent model and the ICanBoogie\ActiveRecord\Table::$parent may be different if the model does not have a schema but inherits it from its parent.

#
protected ICanBoogie\ActiveRecord\RelationCollection $relations

The relations of this model to other models.

The relations of this model to other models.

#

Properties inherited from ICanBoogie\ActiveRecord\Table

$alias, $connection, $implements, $name, $parent, $primary, $schema, $schema_options, $select_join, $unprefixed_name, $update_join

Magic properties

public ICanBoogie\ActiveRecord\ActiveRecordCache $activerecord_cache

The cache use to store activerecords.

public read-only ICanBoogie\ActiveRecord\Model|null $parent

Parent model.

public read-only ICanBoogie\ActiveRecord\ModelCollection $models
public read-only array $all

Retrieve all the records from the model.

public read-only string $activerecord_class

Class of the active records of the model.

public read-only integer $count

The number of records of the model.

public read-only boolean $exists

Whether the SQL table associated with the model exists.

public read-only string $id

The identifier of the model.

public read-only ICanBoogie\ActiveRecord $one

Retrieve the first record from the mode.

public read-only ICanBoogie\ActiveRecord\Model $parent_model

The parent model.

Magic properties inherited from ICanBoogie\ActiveRecord\Table

$alias, $connection, $extended_schema, $name, $primary, $schema, $schema_options, $unprefixed_name

ICanBoogie/ActiveRecord master API documentation generated by ApiGen