An open API service indexing awesome lists of open source software.

https://github.com/kachit/doctrine-datamapper

Simple database layer powered by doctrine2
https://github.com/kachit/doctrine-datamapper

database datamapper doctrine-dbal doctrine2

Last synced: 10 months ago
JSON representation

Simple database layer powered by doctrine2

Awesome Lists containing this project

README

          

Simple doctrine datamapper
===========
[![License](https://poser.pugx.org/leaphly/cart-bundle/license.svg)](https://packagist.org/packages/kachit/doctrine-datamapper)
[![Build Status](https://app.travis-ci.com/Kachit/doctrine-datamapper.svg?branch=master)](https://app.travis-ci.com/github/Kachit/doctrine-datamapper)
[![codecov](https://codecov.io/gh/Kachit/doctrine-datamapper/branch/master/graph/badge.svg?token=SVNIII4H2W)](https://codecov.io/gh/Kachit/doctrine-datamapper)
[![Latest Stable Version](https://poser.pugx.org/kachit/doctrine-datamapper/v/stable)](https://packagist.org/packages/kachit/doctrine-datamapper)
[![Total Downloads](https://poser.pugx.org/kachit/doctrine-datamapper/downloads)](https://packagist.org/packages/kachit/doctrine-datamapper)

Simple datamapper powered by doctrine2

```php
'pdo_pgsql',
'host' => '127.0.0.1',
'port' => 5432,
'dbname' => 'db',
'user' => 'postgres',
'password' => '',
];
$connection = Doctrine\DBAL\DriverManager::getConnection($params);
```

```php
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
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);
```