Junction
+ Inheritance diagram for Junction:

Description

Represents a junction table, derived from an annotated interface.

Interface Annotations:

  • @junction <TABLE>
  • @foreign <COLUMN> <CLASS FQN>

Protected Properties

string[] $classes = []
 [column => class] More...
 
Reflection $ref
 
- Protected Properties inherited from Table
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 $interface)
 
- Public Static Methods inherited from Table
magic static self factory (DB $db, string $name, array $columns)
 

Public Methods

 __construct (DB $db, string $interface)
 
Select EntityInterface[] findAll (string $key, array $match=[])
 Returns a Select for entities referenced by a foreign key. More...
 
string getClass (string $column)
 
string[] getClasses ()
 
Record getRecord (string $column)
 
Record[] getRecords ()
 
int link (array $ids)
 INSERT IGNORE to link entities. More...
 
int unlink (array $ids)
 Typed alias for delete(). More...
 
- Public Methods inherited from Table
 __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...
 

Additional Inherited Members

- Protected Methods inherited from Table
Statement cache (string $key, Closure $prepare)
 Caches a prepared statement. More...
 

Properties

◆ $classes

string [] $classes = []
protected

[column => class]

Constructor

◆ __construct()

__construct ( DB  $db,
string  $interface 
)
Parameters
DB$db
string$interface

Methods

◆ factory()

magic static self factory ( DB  $db,
string  $interface 
)
static
Returns
self

◆ findAll()

Select EntityInterface [] findAll ( string  $key,
array  $match = [] 
)

Returns a Select for entities referenced by a foreign key.

The Select is literal and can be iterated directly.

Parameters
string$keyThe column referencing the class to collect.
array$matchKeyed by junction column.
Returns
Select|EntityInterface[]

◆ getClass()

string getClass ( string  $column)
final
Parameters
string$column
Returns
string

◆ getClasses()

string [] getClasses ( )
final
Returns
string[]

◆ getRecord()

Record getRecord ( string  $column)
Parameters
string$column
Returns
Record

◆ getRecords()

Record [] getRecords ( )
Returns
Record[]

◆ link()

int link ( array  $ids)

INSERT IGNORE to link entities.

Parameters
int[] | EntityInterface[]$idsKeyed by column
Returns
int Rows affected

◆ unlink()

int unlink ( array  $ids)

Typed alias for delete().

Parameters
int[] | EntityInterface[]$idsKeyed by column
Returns
int Rows affected