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 Table

A representation of a database table.

ICanBoogie\Prototyped
Extended by ICanBoogie\ActiveRecord\Table

Direct known subclasses

ICanBoogie\ActiveRecord\Model

Namespace: ICanBoogie\ActiveRecord
Located at ActiveRecord/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 string
# get_name( )

Returns

string
protected string
# get_unprefixed_name( )

Returns

string
protected array|null|string
# get_primary( )

Returns

array|null|string
protected string
# get_alias( )

Returns

string
protected ICanBoogie\ActiveRecord\Schema
# get_schema( )

Returns

ICanBoogie\ActiveRecord\Schema
protected array
# get_schema_options( )

Returns

array
protected ICanBoogie\ActiveRecord\Table
# get_parent( )

Returns

ICanBoogie\ActiveRecord\Table
protected string
# lazy_get_update_join( )

Returns

string
protected string
# lazy_get_select_join( )

Returns

string
protected ICanBoogie\ActiveRecord\Schema
# lazy_get_extended_schema( )

Returns the extended schema.

Returns the extended schema.

Returns

ICanBoogie\ActiveRecord\Schema
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
protected
# map_construct_attributes( array $attributes )

Maps construct attributes.

Maps construct attributes.

Parameters

$attributes
protected
# assert_has_name( )

Asserts that the table has a name.

Asserts that the table has a name.

protected
# assert_has_schema( )

Asserts that the table has a schema.

Asserts that the table has a schema.

protected
# assert_has_connection( )

Asserts that the table has a valid connection.

Asserts that the table has a valid connection.

protected
# assert_parent_is_valid( )

Asserts the parent is valid, if one is specified.

Asserts the parent is valid, if one is specified.

protected
# assert_implements_is_valid( )

Asserts the implements definition is valid.

Asserts the implements definition is valid.

protected
# ensure_has_alias( )

Ensures the table has an alias, make one otherwise.

Ensures the table has an alias, make one otherwise.

protected
# construct_with_parent( ICanBoogie\ActiveRecord\Table $parent )

Construct table with specified parent.

Construct table with specified parent.

From its parent, a table inherits its primary key, schema options, and implements.

Parameters

$parent
public
# install( )

Creates table.

Creates table.

Throws

Exception
if install fails.
public
# uninstall( )

Drops table.

Drops table.

Throws

Exception
if uninstall fails.
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.
public string
# resolve_statement( string $statement )

Resolves statement placeholders.

Resolves 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 string
# quote( string $string, integer $parameter_type = \PDO::PARAM_STR )

Parameters

$string
$parameter_type

Returns

string

See

Connection::quote()
public mixed
# execute( string $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.

Parameters

$query
$args
$options

Returns

mixed
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 array
# filter_values( array $values, boolean|false $extended = false )

Filters mass assignment values.

Filters mass assignment values.

Parameters

$values
$extended

Returns

array
public mixed
# save( array $values, mixed|null $id = null, array $options = [] )

Saves values.

Saves values.

Parameters

$values
$id
$options

Returns

mixed

Throws

Exception
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 mixed
# truncate( )

Truncates table.

Truncates table.

Returns

mixed

Fixme-20081223:

what about extends ?
public mixed
# drop( array $options = [] )

Drops table.

Drops table.

Parameters

$options

Returns

mixed

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 array|null|string $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 ICanBoogie\ActiveRecord\Schema $schema

Schema for the table.

Schema for the table.

#
protected array $schema_options

Schema options provided using ICanBoogie\ActiveRecord\Table::SCHEMA during construct.

Schema options provided using ICanBoogie\ActiveRecord\Table::SCHEMA during construct.

#
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 ICanBoogie\ActiveRecord\Schema $schema

The schema of the table.

public read-only array $schema_options

The options used to create the ICanBoogie\ActiveRecord\Schema instance.

public read-only ICanBoogie\ActiveRecord\Schema $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 master API documentation generated by ApiGen