2017 © Pedro Peláez
 

library doctrine-datamapper

Simple datamapper powered by doctrine 2 dbal

image

kachit/doctrine-datamapper

Simple datamapper powered by doctrine 2 dbal

  • Wednesday, July 4, 2018
  • by kachit
  • Repository
  • 1 Watchers
  • 0 Stars
  • 994 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 20 % Grown

The README.md

Simple doctrine datamapper

License Build Status codecov Latest Stable Version Total Downloads, (*1)

Simple datamapper powered by doctrine2, (*2)

<?php
//create database connection
$params = [
    'driver' => 'pdo_pgsql',
    'host' => '127.0.0.1',
    'port' => 5432,
    'dbname' => 'db',
    'user' => 'postgres',
    'password' => '',
];
$connection = Doctrine\DBAL\DriverManager::getConnection($params);
<?php
//create your table gateway
class FooGateway extends Kachit\Database\Gateway
{
    /**
     * @return string
     */
    public function getTableName(): string
    {
        return 'users';
    }
}

$gateway = new FooGateway($connection);

//fetch by PK
$row = $gateway->fetchByPk(1);

//fetch all without filter
$rows = $gateway->fetchAll();

//fetch list with filter (all active)
$filter = new Kachit\Database\Query\Filter();
$filter->createCondition('active', true);
$rows = $gateway->fetchAll($filter);
<?php
//create entity
class FooEntity extends Kachit\Database\Entity
{
    /**
     * @var int
     */
    protected $id;

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @param int $id
     * @return FooEntity
     */
    public function setId(int $id)
    {
        $this->id = $id;
        return $this;
    }
}
//create mapper
$gateway = new FooGateway();
$entity = new FooEntity();
$mapper = new Kachit\Database\Mapper($gateway, $entity);

//fetch by PK
$entity = $mapper->fetchByPk(1);

//fetch all without filter
$collection = $mapper->fetchAll();

//fetch list with filter (all active)
$filter = new Kachit\Database\Query\Filter();
$filter->createCondition('active', true);
$collection = $mapper->fetchAll($filter);

The Versions

04/07 2018

dev-master

9999999-dev

Simple datamapper powered by doctrine 2 dbal

  Sources   Download

MIT

The Requires

 

The Development Requires

04/07 2018

dev-more-refactor

dev-more-refactor

Simple datamapper powered by doctrine 2 dbal

  Sources   Download

MIT

The Requires

 

The Development Requires

04/07 2018
05/10 2017

dev-refactor

dev-refactor

Simple datamapper powered by doctrine 2

  Sources   Download

MIT

The Requires

 

The Development Requires

01/10 2017

2.0

2.0.0.0

Simple datamapper powered by doctrine 2

  Sources   Download

MIT

The Requires

 

The Development Requires

25/04 2017

1.0

1.0.0.0

Simple datamapper powered by doctrine 2

  Sources   Download

MIT

The Requires

 

The Development Requires