aliengen / pachyderm-orm
A micro ORM for Pachyderm
Installs: 1 142
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 2
Open Issues: 1
Requires
- php: >=8
- aliengen/pachyderm: dev-master
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-01-14 06:21:44 UTC
README
An ORM for the Micro PHP Framework Pachyderm
Declare a Model
<?php namespace App\Models; use Pachyderm\Orm\Model; class MyEntity extends Model { public $table = 'my_entities'; public $primary_key = 'entity_id'; }
Use a model
Create
$data = [ 'column_1' => 'value of column 1', 'column_2' => 'value of column 2', ]; $entity = MyEntity::create($data); echo 'Column 1: ', $entity->column_1;
Read
Retrieve by id
$entity_id = 42; $entity = MyEntity::find($entity_id); echo 'Column 1: ', $entity->column_1;
Retrieve a list of entities
$entities = MyEntity::findAll(); foreach($entities AS $entity) { echo 'Column 1: ', $entity->column_1; }
Retrieve a list of entities using filters
$entities = MyEntity::where('column_2', '=', 42)->get(); foreach($entities AS $entity) { echo 'Column 1: ', $entity->column_1; }
Update
$entity->column_1 = 'My new value'; $entity->save(); echo 'Column 1: ', $entity->column_1;
Delete
$entity->delete();