ICanBoogie/ActiveRecord v2.2.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • ActiveRecord

Classes

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

Interfaces

  • ActiveRecordCache
  • Exception

Traits

  • CreatedAtProperty
  • DateTimeProperty
  • UpdatedAtProperty

Exceptions

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

Functions

  • extract_charset_and_collate
  • get_model

Class Table

A representation of a database table.

ICanBoogie\Object
Extended by ICanBoogie\ActiveRecord\Table

Direct known subclasses

ICanBoogie\ActiveRecord\Model

Namespace: ICanBoogie\ActiveRecord
Located at Table.php

Methods summary

protected ICanBoogie\ActiveRecord\Connection
# get_connection( )

Returns the connection used by the table.

Returns the connection used by the table.

Returns

ICanBoogie\ActiveRecord\Connection
protected
# get_name( )
protected
# get_unprefixed_name( )
protected
# get_primary( )
protected
# get_alias( )
protected
# get_schema( )
protected
# get_parent( )
public
# __construct( array $attributes )

Initializes the following properties: ICanBoogie\ActiveRecord\Table::$alias, ICanBoogie\ActiveRecord\Table::$connection, ICanBoogie\ActiveRecord\Table::$implements, ICanBoogie\ActiveRecord\Table::$unprefixed_name, ICanBoogie\ActiveRecord\Table::$schema and ICanBoogie\ActiveRecord\Table::$parent.

Initializes the following properties: ICanBoogie\ActiveRecord\Table::$alias, ICanBoogie\ActiveRecord\Table::$connection, ICanBoogie\ActiveRecord\Table::$implements, ICanBoogie\ActiveRecord\Table::$unprefixed_name, ICanBoogie\ActiveRecord\Table::$schema and ICanBoogie\ActiveRecord\Table::$parent.

Parameters

$attributes

Throws

InvalidArgumentException
if the ICanBoogie\ActiveRecord\Table::CONNECTION attribute is empty.
public ICanBoogie\ActiveRecord\Statement
# __invoke( string $query, array $args = [], array $options = [] )

Alias to ICanBoogie\ActiveRecord\Table::query().

Alias to ICanBoogie\ActiveRecord\Table::query().

Parameters

$query
$args
$options

Returns

ICanBoogie\ActiveRecord\Statement
public
# install( )
public
# uninstall( )
public boolean
# is_installed( )

Checks whether the table is installed.

Checks whether the table is installed.

Returns

boolean
true if the table exists, false otherwise.
protected array
# lazy_get_extended_schema( )

Returns the extended schema.

Returns the extended schema.

Returns

array
public string
# resolve_statement( string $statement )

Resolve statement placeholders.

Resolve statement placeholders.

The following placeholder are replaced:

  • {alias}: The alias of the table.
  • {prefix}: The prefix used for the tables of the connection.
  • {primary}: The primary key of the table.
  • {self}: The name of the table.
  • {self_and_related}: The escaped name of the table and the possible JOIN clauses.

Note: If the table has a multi-column primary keys {primary} is replaced by __multicolumn_primary__<concatened_columns> where <concatened_columns> is a the columns concatenated with an underscore ("_") as separator. For instance, if a table primary key is made of columns "p1" and "p2", {primary} is replaced by __multicolumn_primary__p1_p2. It's not very helpful, but we still have to decide what to do with this.

Parameters

$statement
The statement to resolve.

Returns

string
public ICanBoogie\ActiveRecord\Statement
# prepare( $query, $options = [] )

Interface to the connection's prepare method.

Interface to the connection's prepare method.

The statement is resolved by the ICanBoogie\ActiveRecord\Table::resolve_statement() method before the call is forwarded.

Returns

ICanBoogie\ActiveRecord\Statement

Inheritdoc

public
# quote( $string, $parameter_type = \PDO::PARAM_STR )
public mixed
# execute( $query, array $args = [], array $options = [] )

Executes a statement.

Executes a statement.

The statement is prepared by the ICanBoogie\ActiveRecord\Table::prepare() method before it is executed.

Returns

mixed

Inheritdoc

public ICanBoogie\ActiveRecord\Statement
# query( string $query, array $args = [], array $options = [] )

Interface to the connection's query() method.

Interface to the connection's query() method.

The statement is resolved using the resolve_statement() method and prepared.

Parameters

$query
$args
$options

Returns

ICanBoogie\ActiveRecord\Statement
protected
# filter_values( array $values, $extended = false )
public
# save( array $values, $id = null, array $options = [] )
protected
# save_callback( array $values, $id = null, array $options = [] )
public mixed
# insert( array $values, array $options = [] )

Inserts values into the table.

Inserts values into the table.

Parameters

$values
The values to insert.
$options

The following options can be used: - ignore: Ignore duplicate errors. - on duplicate: specifies the column to update on duplicate, and the values to update them. If true the $values array is used, after the primary keys has been removed.

Returns

mixed
public boolean
# update( array $values, mixed $key )

Update the values of an entry.

Update the values of an entry.

Even if the entry is spread over multiple tables, all the tables are updated in a single step.

Parameters

$values
$key

Returns

boolean
public boolean
# delete( mixed $key )

Deletes a record.

Deletes a record.

Parameters

$key
Identifier of the record.

Returns

boolean
public
# truncate( )
public
# drop( array $options = [] )

Constants summary

string ALIAS

Alias of the table.

Alias of the table.

# 'alias'
string CONNECTION

Connection.

Connection.

# 'connection'
string EXTENDING

Extended model.

Extended model.

# 'extends'
string IMPLEMENTING
# 'implements'
string NAME

Unprefixed Name of the table.

Unprefixed Name of the table.

# 'name'
string SCHEMA

Schema of the table.

Schema of the table.

# 'schema'

Properties summary

protected ICanBoogie\ActiveRecord\Connection $connection

A database connection.

A database connection.

#
protected string $name

Name of the table, including the prefix defined by the model's connection.

Name of the table, including the prefix defined by the model's connection.

#
protected $unprefixed_name

The unprefixed name of the table.

The unprefixed name of the table.

Return

string
#
protected mixed $primary

Primary key of the table, retrieved from the schema defined using the ICanBoogie\ActiveRecord\Table::SCHEMA attribute.

Primary key of the table, retrieved from the schema defined using the ICanBoogie\ActiveRecord\Table::SCHEMA attribute.

#
protected string $alias

Alias for the table's name, which can be defined using the ICanBoogie\ActiveRecord\Table::ALIAS attribute or automatically created.

Alias for the table's name, which can be defined using the ICanBoogie\ActiveRecord\Table::ALIAS attribute or automatically created.

The "{primary}" placeholder used in queries is replaced by the properties value.

#
protected array $schema

Schema for the table.

Schema for the table.

The "{alias}" placeholder used in queries is replaced by the properties value.

#
protected ICanBoogie\ActiveRecord\Table $parent

The parent is used when the table is in a hierarchy, which is the case if the table extends another table.

The parent is used when the table is in a hierarchy, which is the case if the table extends another table.

#
protected array $implements
# []
protected string $update_join

SQL fragment for the FROM clause of the query, made of the table's name and alias and those of the hierarchy.

SQL fragment for the FROM clause of the query, made of the table's name and alias and those of the hierarchy.

#
protected string $select_join

SQL fragment for the FROM clause of the query, made of the table's name and alias and those of the related tables, inherited and implemented.

SQL fragment for the FROM clause of the query, made of the table's name and alias and those of the related tables, inherited and implemented.

The "{self_and_related}" placeholder used in queries is replaced by the properties value.

#

Magic properties

public read-only ICanBoogie\ActiveRecord\Connection $connection

Connection used by the table.

public read-only array $schema

The schema of the table.

public read-only array $extended_schema

The extended schema of the table.

public read-only string $name

Name of the table, which might include a prefix.

public read-only string $unprefixed_name

Unprefixed name of the table.

public read-only string|array|null $primary

Primary key of the table, or null if there is none.

public read-only string $alias

The alias name of the table.

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

The parent of the table.

ICanBoogie/ActiveRecord v2.2.0 API documentation generated by ApiGen