EAV
+ Inheritance diagram for EAV:

Description

Array storage in an extension table.

Protected Properties

string $type
 The scalar storage type for the value column (implied NOT NULL). More...
 
- 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 $name, string $type='string')
 
- Public Static Methods inherited from Table
magic static self factory (DB $db, string $name, array $columns)
 

Public Methods

 __construct (DB $db, string $name, string $type='string')
 
bool exists (int $id, string $attribute)
 Whether an entity has an attribute. More...
 
Select findAll (array $match)
 Self-joins to return a Select for the entity column, matching on attribute and value. More...
 
string getType ()
 
scalar[] load (int $id)
 Returns an entity's attributes. More...
 
scalar[][] loadAll (array $ids)
 Returns associative attribute-value arrays for the given IDs. More...
 
$this save (int $id, array $values)
 Upserts an entity's attributes with those given. 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...
 

Protected Methods

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

Properties

◆ $type

string $type
protected

The scalar storage type for the value column (implied NOT NULL).

Constructor

◆ __construct()

__construct ( DB  $db,
string  $name,
string  $type = 'string' 
)
Parameters
DB$db
string$name
string$type

Methods

◆ exists()

bool exists ( int  $id,
string  $attribute 
)

Whether an entity has an attribute.

Parameters
int$id
string$attribute
Returns
bool

◆ factory()

magic static self factory ( DB  $db,
string  $name,
string  $type = 'string' 
)
static
Returns
self

◆ findAll()

Select findAll ( array  $match)

Self-joins to return a Select for the entity column, matching on attribute and value.

See also
Predicate::match()
Parameters
array$match[attribute => value]. If empty, selects all IDs for entities having at least one attribute.
Returns
Select

◆ getType()

string getType ( )
final
Returns
string

◆ load()

scalar [] load ( int  $id)

Returns an entity's attributes.

Parameters
int$id
Returns
scalar[] [attribute => value]

◆ loadAll()

scalar [][] loadAll ( array  $ids)

Returns associative attribute-value arrays for the given IDs.

Parameters
int[]$ids
Returns
scalar[][] [id => attribute => value]

◆ save()

$this save ( int  $id,
array  $values 
)

Upserts an entity's attributes with those given.

Stored attributes not given here are pruned.

NULL attributes are also pruned.

Parameters
int$id
array$values[attribute => value]
Returns
$this

◆ setType()

scalar setType (   $value)
protected
Parameters
scalar$value
Returns
scalar