2017 © Pedro Peláez
 

library simpleorm

что то вроде ORM

image

dimaxz/simpleorm

что то вроде ORM

  • Thursday, September 1, 2016
  • by dimaxz
  • Repository
  • 2 Watchers
  • 1 Stars
  • 50 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

SimpleORM

Scrutinizer Code Quality Code Coverage Build Status, (*1)

Features

  • Framework agnostic
  • Lazy loading
  • Soft Deletes
  • Value Objects
  • Support Relationships

find by id, (*2)

$Price = $PriceMapper->findById(44);
//or
$Price = $PriceMapper->useJoins()->findById(45);

save, (*3)

$Price->getDatafile()->setIsEnabled(0);
$Price->setName('test');
if($PriceMapper->save($Price)){
  echo 'save success';
}

delete, (*4)

if($PriceMapper->delete($Price)){
  echo 'delete success';
}

find by criteria, (*5)

use SimpleORM\Specification;
$SearchCriteria = (new Specification())->setWhere('tablename',$tablename);
$Price = $this->PriceMapper->findBySpecification($SearchCriteria);

save with relations, (*6)

$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, (*7)

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();
                    }   
                ])
            ;

    }   
}

The Versions

01/09 2016

dev-master

9999999-dev

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

01/09 2016

v1.2.2

1.2.2.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

30/08 2016

dev-fix/factory-criteria

dev-fix/factory-criteria

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

14/03 2016

v1.2.1

1.2.1.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

04/03 2016

v1.2

1.2.0.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

01/03 2016

dev-feature/validation

dev-feature/validation

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

19/01 2016

v1.1.2

1.1.2.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

17/12 2015

v1.1.1

1.1.1.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

11/12 2015

v1.0.1

1.0.1.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets

10/12 2015

v1.0

1.0.0.0

что то вроде ORM

  Sources   Download

The Requires

 

by Dmitriy Lanets