Database storage and access using annotations.
Documentation: https://hfw.github.io/db
/**
* @record my_table
*/
class MyClass implements Helix\DB\EntityInterface, ArrayAccess {
use Helix\DB\AttributesTrait;
/**
* "id" is a required column.
* @column
* @var int
*/
protected $id = 0;
/**
* @column
* @var string
*/
protected $myColumn;
/**
* @eav foo_eav
* @var array
*/
protected $attributes;
/**
* @return int
*/
final public function getId() {
return $this->id;
}
}
- Columns must be named the same as their respective properties.
- EAV tables must have 3 columns:
entity
,attribute
, andvalue
.entity
must be a foreign key.entity
andattribute
must form the primary key.
Interfaces can be annotated to act as junctions.
/**
* @junction foo_bar
* @foreign foo_id Foo
* @foreign bar_id Bar
*/
interface FooBar { }
- The interfaces don't have to be implemented.
- The referenced classes may be identical.
- MySQL
- SQLite