ICanBoogie
  • Documentation
  • API Reference
  • ActiveRecord 4.0.x
Namespaces
  • ICanBoogie
    • ActiveRecord
      • ActiveRecordCache
      • Driver
      • Property
      • Validate
        • Reader
        • Validator
        • ValidatorProvider
Classes
  • BelongsToRelation
  • Connection
  • ConnectionCollection
  • ConnectionOptions
  • HasManyRelation
  • Model
  • ModelCollection
  • ModelProvider
  • Query
  • Relation
  • RelationCollection
  • RelationNotDefined
  • Schema
  • SchemaColumn
  • Statement
  • Table
Interfaces
  • ActiveRecordCache
  • Driver
  • Exception
Exceptions
  • ActiveRecordClassNotValid
  • ConnectionAlreadyEstablished
  • ConnectionNotDefined
  • ConnectionNotEstablished
  • DriverNotDefined
  • ModelAlreadyInstantiated
  • ModelNotDefined
  • RecordNotFound
  • RecordNotValid
  • ScopeNotDefined
  • StatementInvocationFailed
  • StatementNotValid
  • UnableToSetFetchMode

Class Table

A representation of a database table.

ICanBoogie\Prototyped
┗ ICanBoogie\ActiveRecord\Table

Direct known subclasses

ICanBoogie\ActiveRecord\Model

Namespace: ICanBoogie\ActiveRecord
Located at ActiveRecord/Table.php

Methods summary

protected get_connection( void ) : ICanBoogie\ActiveRecord\Connection

Returns the connection used by the table.

Returns the connection used by the table.

Returns

ICanBoogie\ActiveRecord\Connection
protected get_name( void ) : string

Returns

string
protected get_unprefixed_name( void ) : string

Returns

string
protected get_primary( void ) : array|null|string

Returns

array|null|string
protected get_alias( void ) : string

Returns

string
protected get_schema( void ) : ICanBoogie\ActiveRecord\Schema

Returns

ICanBoogie\ActiveRecord\Schema
protected get_schema_options( void ) : array

Returns

array
protected get_parent( void ) : ICanBoogie\ActiveRecord\Table

Returns

ICanBoogie\ActiveRecord\Table
protected lazy_get_update_join( void ) : string

Returns

string
protected lazy_get_select_join( void ) : string

Returns

string
protected lazy_get_extended_schema( void ) : ICanBoogie\ActiveRecord\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 __invoke( string $query, array $args = [], array $options = [] ) : ICanBoogie\ActiveRecord\Statement

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( void )

Asserts that the table has a name.

Asserts that the table has a name.

protected assert_has_schema( void )

Asserts that the table has a schema.

Asserts that the table has a schema.

protected assert_has_connection( void )

Asserts that the table has a valid connection.

Asserts that the table has a valid connection.

protected assert_parent_is_valid( void )

Asserts the parent is valid, if one is specified.

Asserts the parent is valid, if one is specified.

protected assert_implements_is_valid( void )

Asserts the implements definition is valid.

Asserts the implements definition is valid.

protected ensure_has_alias( void )

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( void )

Creates table.

Creates table.

Throws

Exception
if install fails.
public uninstall( void )

Drops table.

Drops table.

Throws

Exception
if uninstall fails.
public is_installed( void ) : boolean

Checks whether the table is installed.

Checks whether the table is installed.

Returns

boolean
true if the table exists, false otherwise.
public resolve_statement( string $statement ) : string

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 prepare( $query, $options = [] ) : ICanBoogie\ActiveRecord\Statement

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

Parameters

$string
$parameter_type

Returns

string

See

Connection::quote()
public execute( string $query, array $args = [], array $options = [] ) : mixed

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 query( string $query, array $args = [], array $options = [] ) : ICanBoogie\ActiveRecord\Statement

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, boolean|false $extended = false ) : array

Filters mass assignment values.

Filters mass assignment values.

Parameters

$values
$extended

Returns

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

Saves values.

Saves values.

Parameters

$values
$id
$options

Returns

mixed

Throws

Exception
protected save_callback( array $values, $id = null, array $options = [] )
public insert( array $values, array $options = [] ) : mixed

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 update( array $values, mixed $key ) : boolean

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 delete( mixed $key ) : boolean

Deletes a record.

Deletes a record.

Parameters

$key
Identifier of the record.

Returns

boolean
public truncate( void ) : mixed

Truncates table.

Truncates table.

Returns

mixed

Fixme-20081223:

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

Drops table.

Drops table.

Parameters

$options

Returns

mixed

Constants summary

ALIAS : string

Alias of the table.

Alias of the table.

'alias'
CONNECTION : string

Connection.

Connection.

'connection'
EXTENDING : string

Extended model.

Extended model.

'extends'
IMPLEMENTING : string
'implements'
NAME : string

Unprefixed Name of the table.

Unprefixed Name of the table.

'name'
SCHEMA : string

Schema of the table.

Schema of the table.

'schema'

Properties summary

protected $connection : ICanBoogie\ActiveRecord\Connection

A database connection.

A database connection.


		
protected $name : string

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 $primary : array|null|string

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 $alias : string

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

Schema for the table.

Schema for the table.


		
protected $schema_options : array

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

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


		
protected $parent : ICanBoogie\ActiveRecord\Table

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 $implements : array
[]
protected $update_join : string

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 $select_join : string

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 $connection : ICanBoogie\ActiveRecord\Connection

Connection used by the table.

public read-only $schema : ICanBoogie\ActiveRecord\Schema

The schema of the table.

public read-only $schema_options : array

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

public read-only $extended_schema : ICanBoogie\ActiveRecord\Schema

The extended schema of the table.

public read-only $name : string

Name of the table, which might include a prefix.

public read-only $unprefixed_name : string

Unprefixed name of the table.

public read-only $primary : string|array|null

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

public read-only $alias : string

The alias name of the table.

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

The parent of the table.

ActiveRecord 4.0.x – Check on GitHub – API documentation generated by ApiGen