ICanBoogie
  • Documentation
  • API Reference
  • ActiveRecord v2.2.0
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

Class Table

A representation of a database table.

ICanBoogie\Object
┗ ICanBoogie\ActiveRecord\Table

Direct known subclasses

ICanBoogie\ActiveRecord\Model

Namespace: ICanBoogie\ActiveRecord
Located at 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 )
protected get_unprefixed_name( void )
protected get_primary( void )
protected get_alias( void )
protected get_schema( void )
protected get_parent( void )
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
public install( void )
public uninstall( void )
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.
protected lazy_get_extended_schema( void ) : array

Returns the extended schema.

Returns the extended schema.

Returns

array
public resolve_statement( string $statement ) : string

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 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, $parameter_type = \PDO::PARAM_STR )
public execute( $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.

Returns

mixed

Inheritdoc

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, $extended = false )
public save( array $values, $id = null, array $options = [] )
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 )
public drop( array $options = [] )

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 : mixed

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 : array

Schema for the table.

Schema for the table.

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


		
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 : array

The schema of the table.

public read-only $extended_schema : array

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 v2.2.0 – Check on GitHub – API documentation generated by ApiGen