Table
+ Inheritance diagram for Table:

Description

Table manipulation using arrays.

Accessing the table as an array produces Column instances.

Immutable:
Mutations operate on and return clones.

Protected Properties

Statement[] $_cache = []
 Prepared statement cache, keyed by function name. More...
 
Column[] $columns = []
 [name => Column] More...
 
string $name
 
- Protected Properties inherited from AbstractTable
DB $db
 

Public Static Methods

magic static self factory (DB $db, string $name, array $columns)
 

Public Methods

 __construct (DB $db, string $name, array $columns)
 
string __toString ()
 Returns the table name. More...
 
int apply (array $values)
 INSERT IGNORE More...
 
int count (array $match=[])
 
int delete (array $match)
 Executes a deletion using arbitrary columns. More...
 
Column[] getColumns ()
 
string getName ()
 
Statement insert (array $values)
 Executes an insertion using arbitrary columns. More...
 
Column offsetGet ($column)
 
Select array[] select ($expressions=[' *'])
 Returns a selection object for columns or expressions in the table. More...
 
Table setName (string $name)
 Returns an aliased clone for joins. More...
 
int update (array $values, array $match)
 Executes an update using arbitrary columns. More...
 
- Public Methods inherited from AbstractTable
 __construct (DB $db)
 
bool offsetExists ($column)
 
void offsetSet ($offset, $value)
 Throws. More...
 
void offsetUnset ($name)
 Throws. More...
 

Protected Methods

Statement cache (string $key, Closure $prepare)
 Caches a prepared statement. More...
 

Properties

◆ $_cache

Statement [] $_cache = []
protected

Prepared statement cache, keyed by function name.

◆ $columns

Column [] $columns = []
protected

[name => Column]

Constructor

◆ __construct()

__construct ( DB  $db,
string  $name,
array  $columns 
)
Parameters
DB$db
string$name
string[]$columns

Methods

◆ __toString()

string __toString ( )
final

Returns the table name.

Returns
string

Reimplemented from AbstractTable.

◆ apply()

int apply ( array  $values)

INSERT IGNORE

Parameters
array$values
Returns
int Rows affected.

◆ cache()

Statement cache ( string  $key,
Closure  $prepare 
)
protected

Caches a prepared statement.

Parameters
string$key
Closure$prepare():Statement
Returns
Statement

◆ count()

int count ( array  $match = [])
Parameters
array$match[a => b]
Returns
int

◆ delete()

int delete ( array  $match)

Executes a deletion using arbitrary columns.

See also
Predicate::match()
Parameters
array$match
Returns
int Rows affected.

◆ factory()

magic static self factory ( DB  $db,
string  $name,
array  $columns 
)
static
Returns
self

◆ getColumns()

Column [] getColumns ( )
Returns
Column[]

Reimplemented from AbstractTable.

◆ getName()

string getName ( )
final
Returns
string

◆ insert()

Statement insert ( array  $values)

Executes an insertion using arbitrary columns.

Parameters
array$values
Returns
Statement

◆ offsetGet()

Column offsetGet (   $column)
Parameters
string$column
Returns
Column

Reimplemented from AbstractTable.

◆ select()

Select array [] select (   $expressions = ['*'])

Returns a selection object for columns or expressions in the table.

Parameters
string | string[]$expressions
Returns
Select|array[]

◆ setName()

Table setName ( string  $name)

Returns an aliased clone for joins.

Columns are also re-qualified.

If you want to rename the table in the schema, use Schema::renameTable()

Parameters
string$name
Returns
Table

◆ update()

int update ( array  $values,
array  $match 
)

Executes an update using arbitrary columns.

See also
Predicate::match()
Parameters
array$values
array$match
Returns
int Rows affected.