dimaxz / simpleorm
что то вроде ORM
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/dimaxz/simpleorm
Requires
- league/container: 2.0.*
- wixel/gump: 1.3.*
This package is not auto-updated.
Last update: 2025-09-28 00:34:39 UTC
README
Features
- Framework agnostic
- Lazy loading
- Soft Deletes
- Value Objects
- Support Relationships
find by id
$Price = $PriceMapper->findById(44); //or $Price = $PriceMapper->useJoins()->findById(45);
save
$Price->getDatafile()->setIsEnabled(0); $Price->setName('test'); if($PriceMapper->save($Price)){ echo 'save success'; }
delete
if($PriceMapper->delete($Price)){ echo 'delete success'; }
find by criteria
use SimpleORM\Specification; $SearchCriteria = (new Specification())->setWhere('tablename',$tablename); $Price = $this->PriceMapper->findBySpecification($SearchCriteria);
save with relations
$UserGroup = new UserGroup('admin','администратор'); $User = new User('master','mail@test.ru', '65829e542dd151f443',$UserGroup); $User->setName('Тестовый пользюк 2'); $City = new City('Москва'); $Address = new UserAddress($City,'610110','Чернышевского'); $User->setAddress($Address); if($UserMapper->save($User)){ echo 'save success'; }
use ValueObject
use SimpleORM\AbstractDataMapper, ValueObject\UserPhoto; class UserMapper extends AbstractDataMapper { /** * Настройка полей */ protected function setMappingFields() { //вариант 1 $this ->addMappingField('id', [ 'field' => 'usr_id', 'primary' => true ] ) ->addMappingField('photo',[ 'name' => 'usr_photo', 'build' => function($row){ return new UserPhoto($row['usr_photo']); }, 'unbuild' => function(UserPhoto $UserPhoto){ return $UserPhoto->getPath(); } ]) ; } }