Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • ActiveRecordCache
  • CollectDependenciesEvent
  • Connection
  • Connections
  • DateTimePropertySupport
  • Helpers
  • Hooks
  • Model
  • Models
  • Query
  • RunTimeActiveRecordCache
  • Statement
  • Table

Interfaces

  • ActiveRecordCacheInterface

Traits

  • CreatedAtProperty
  • DateTimeProperty
  • UpdatedAtProperty

Exceptions

  • ActiveRecordException
  • ConnectionAlreadyEstablished
  • ConnectionNotDefined
  • ConnectionNotEstablished
  • ModelAlreadyInstantiated
  • ModelNotDefined
  • RecordNotFound
  • ScopeNotDefined
  • StatementInvalid

Functions

  • get_model

Class Model

Base class for activerecord models.

ICanBoogie\Object implements ICanBoogie\ToArrayRecursive uses ICanBoogie\ToArrayRecursiveTrait, ICanBoogie\PrototypeTrait
Extended by ICanBoogie\ActiveRecord\Table
Extended by ICanBoogie\ActiveRecord\Model implements ArrayAccess

Direct known subclasses

Icybee\ActiveRecord\Model\Constructor, Icybee\Modules\Comments\Model, Icybee\Modules\Pages\ContentModel, Icybee\Modules\Registry\Model, Icybee\Modules\Sites\Model, Icybee\Modules\Taxonomy\Terms\Model, Icybee\Modules\Taxonomy\Vocabulary\Model, Icybee\Modules\Users\NonceLogin\TicketModel, Icybee\Modules\Users\Roles\Model

Indirect known subclasses

Icybee\Modules\Articles\Model, Icybee\Modules\Contents\Model, Icybee\Modules\Files\Model, Icybee\Modules\Forms\Model, Icybee\Modules\Images\Model, Icybee\Modules\Members\Model, Icybee\Modules\Nodes\Model, Icybee\Modules\Pages\Model, Icybee\Modules\Users\Model

Namespace: ICanBoogie\ActiveRecord
Located at vendor/icanboogie/activerecord/lib/model.php

Methods summary

public
# __construct( array $tags )

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

$tags
array
$tags Tags used to construct the model.

Throws

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

Overrides

ICanBoogie\ActiveRecord\Table::__construct
public ICanBoogie\ActiveRecord\Model
# belongs_to( string|array $belongs_to )

Handles the _belongs to_ relationship of the model.

Handles the _belongs to_ relationship of the model.

$cars->belongs_to([ $drivers, $brands ]);
# or
$cars->belongs_to([ 'drivers', 'brands' ]);
# or
$cars->belongs_to($drivers, $brands);
# or
$cars->belongs_to($drivers);
$cars->belongs_to($brands);

Parameters

$belongs_to
string|array
$belongs_to

Returns

ICanBoogie\ActiveRecord\Model

Throws

ICanBoogie\ActiveRecord\ActiveRecordException
if the class of the active record is ICanBoogie\ActiveRecord.
public mixed
# __call( string $method, array $arguments )

Handles query methods, dynamic filters and scopes.

Handles query methods, dynamic filters and scopes.

Parameters

$method
string
$method
$arguments
array
$arguments

Returns

mixed

Overrides

ICanBoogie\Object::__call
public mixed
# __get( string $property )

Overrides the method to handle scopes.

Overrides the method to handle scopes.

Parameters

$property
string
$property

Returns

mixed
The value of the inaccessible property.

Throws

PropertyNotReadable
when the property has a protected or private scope and no suitable callback could be found to retrieve its value.
PropertyNotDefined
when the property is undefined and there is no suitable callback to retrieve its values.

Overrides

ICanBoogie\Object::__get
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|array
# find( mixed $key )

Finds a record or a collection of records.

Finds a record or a collection of records.

Parameters

$key
mixed
$key A key or an array of keys.

Returns

ICanBoogie\ActiveRecord|array
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
# save( array $properties, mixed $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.

Overrides

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

Eliminates the record from the cache.

Eliminates the record from the cache.

Parameters

$key
mixed
$key Identifier of the record.

Returns

boolean

Overrides

ICanBoogie\ActiveRecord\Table::delete
protected
# store( ICanBoogie\ActiveRecord $record )

Stores a record in the records cache.

Stores a record in the records cache.

Parameters

$record
ICanBoogie\ActiveRecord
$record The record to store.

TODO-20140414:

Remove the method and use $activerecord_cache
protected ICanBoogie\ActiveRecord|null
# retrieve( integer $key )

Retrieves a record from the records cache.

Retrieves a record from the records cache.

Parameters

$key
integer
$key

Returns

ICanBoogie\ActiveRecord|null
Returns the active record found in the cache or null if it wasn't there.

TODO-20140414:

Remove the method and use $activerecord_cache
protected
# eliminate( integer $key )

Eliminates an object from the cache.

Eliminates an object from the cache.

Parameters

$key
integer
$key

TODO-20140414:

Remove the method and use $activerecord_cache
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 array[]ActiveRecord
# get_all( )

Returns all the records of the model.

Returns all the records of the model.

Returns

array[]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
string
$name Scope name.

Returns

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

Calls a given scope on the active record query specified in the scope_args.

Calls a given scope on the active record query specified in the scope_args.

Parameters

$scope_name
string
$scope_name Name of the scope to apply to the query.
$scope_args
array
$scope_args Arguments to forward to the scope method.

Returns

ICanBoogie\ActiveRecord\Query

Throws

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

Offsets are not settable.

Offsets are not settable.

Throws

ICanBoogie\OffsetNotWritable
when one tries to write an offset.

Implementation of

ArrayAccess::offsetSet()
public
# offsetExists( mixed $key )

Checks if the record identified by the given key exists.

Checks if the record identified by the given key exists.

The call is forwarded to exists().

Implementation of

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

Deletes the record specified by the given key.

Deletes the record specified by the given key.

See

Model::delete();

Implementation of

ArrayAccess::offsetUnset()
public
# offsetGet( mixed $key )

Alias for the ICanBoogie\ActiveRecord\Model::find() method.

Alias for the ICanBoogie\ActiveRecord\Model::find() method.

See

ICanBoogie\ActiveRecord\Model::find()

Implementation of

ArrayAccess::offsetGet()
public ICanBoogie\ActiveRecord
# new_record( )

Creates a new active record instance.

Creates a new active record instance.

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

Returns

ICanBoogie\ActiveRecord

Methods inherited from ICanBoogie\ActiveRecord\Table

__invoke(), drop(), execute(), filter_values(), get_alias(), get_connection(), get_name(), get_name_unprefixed(), get_parent(), get_primary(), get_schema(), insert(), install(), is_installed(), lazy_get_extended_schema(), prepare(), query(), quote(), resolve_statement(), save_callback(), truncate(), uninstall(), update()

Methods inherited from ICanBoogie\Object

from(), resolve_facade_properties(), resolve_private_properties(), to_array(), to_json()

Methods inherited from ICanBoogie\ToArrayRecursive

to_array_recursive()

Methods used from ICanBoogie\ToArrayRecursiveTrait

to_array_recursive()

Methods used from ICanBoogie\PrototypeTrait

__set(), __sleep(), __wakeup(), get_prototype(), has_method(), has_property(), last_chance_get(), last_chance_set()

Magic methods summary

public ICanBoogie\ActiveRecord\Query
# select( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::$select.

The method is forwarded to ICanBoogie\ActiveRecord\Query::$select.

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::joins().

The method is forwarded to ICanBoogie\ActiveRecord\Query::joins().

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::where().

The method is forwarded to ICanBoogie\ActiveRecord\Query::where().

Parameters

$conditions_args

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::$group.

The method is forwarded to ICanBoogie\ActiveRecord\Query::$group.

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::$order.

The method is forwarded to ICanBoogie\ActiveRecord\Query::$order.

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::$limit.

The method is forwarded to ICanBoogie\ActiveRecord\Query::$limit.

Parameters

$offset

Returns

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

The method is forwarded to ICanBoogie\ActiveRecord\Query::$offset.

The method is forwarded to ICanBoogie\ActiveRecord\Query::$offset.

Returns

ICanBoogie\ActiveRecord\Query
public boolean
# exists( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::exists().

The method is forwarded to ICanBoogie\ActiveRecord\Query::exists().

Returns

boolean
public mixed
# count( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::count().

The method is forwarded to ICanBoogie\ActiveRecord\Query::count().

Returns

mixed
public string
# average( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::average().

The method is forwarded to ICanBoogie\ActiveRecord\Query::average().

Returns

string
public string
# maximum( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::maximum().

The method is forwarded to ICanBoogie\ActiveRecord\Query::maximum().

Returns

string
public string
# minimum( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::minimum().

The method is forwarded to ICanBoogie\ActiveRecord\Query::minimum().

Returns

string
public integer
# sum( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::sum().

The method is forwarded to ICanBoogie\ActiveRecord\Query::sum().

Returns

integer
public array
# all( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::all().

The method is forwarded to ICanBoogie\ActiveRecord\Query::all().

Returns

array
public ICanBoogie\ActiveRecord
# one( )

The method is forwarded to ICanBoogie\ActiveRecord\Query::one().

The method is forwarded to ICanBoogie\ActiveRecord\Query::one().

Returns

ICanBoogie\ActiveRecord

Constants summary

string T_ACTIVERECORD_CLASS 'activerecord_class'
#
string T_CLASS 'class'
#
string T_ID 'id'
#
string ACTIVERECORD_CLASS 'activerecord_class'
#
string BELONGS_TO 'belongs_to'
#
string CLASSNAME 'class'
#
string ID 'id'
#

Constants inherited from ICanBoogie\ActiveRecord\Table

ALIAS, CONNECTION, EXTENDING, IMPLEMENTING, NAME, SCHEMA, T_ALIAS, T_CONNECTION, T_EXTENDS, T_IMPLEMENTS, T_NAME, T_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.

Properties inherited from ICanBoogie\ActiveRecord\Table

$alias, $connection, $implements, $name, $name_unprefixed, $parent, $primary, $schema, $select_join, $update_join

Magic properties

public ICanBoogie\ActiveRecord\ActiveRecordCacheInterface $activerecord_cache
#

The cache use to store activerecords.

The cache use to store activerecords.

public read-only array $all
#

Retrieve all the records from the model.

Retrieve all the records from the model.

public read-only string $activerecord_class
#

Class of the active records of the model.

Class of the active records of the model.

public read-only integer $count
#

The number of records of the model.

The number of records of the model.

public read-only boolean $exists
#

Whether the SQL table associated with the model exists.

Whether the SQL table associated with the model exists.

public read-only string $id
#

The identifier of the model.

The identifier of the model.

Magic properties inherited from ICanBoogie\ActiveRecord\Table

$alias, $connection, $extended_schema, $name_unprefixed, $parent, $primary, $schema

Magic properties inherited from ICanBoogie\Object

$prototype

Autodoc API documentation generated by ApiGen 2.8.0