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
- Host: GitHub
- URL: https://github.com/kachit/doctrine-datamapper
- Owner: Kachit
- License: mit
- Created: 2016-12-14T11:13:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-12T18:12:50.000Z (over 4 years ago)
- Last Synced: 2025-04-09T23:51:02.934Z (10 months ago)
- Topics: database, datamapper, doctrine-dbal, doctrine2
- Language: PHP
- Homepage:
- Size: 229 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple doctrine datamapper
===========
[](https://packagist.org/packages/kachit/doctrine-datamapper)
[](https://app.travis-ci.com/github/Kachit/doctrine-datamapper)
[](https://codecov.io/gh/Kachit/doctrine-datamapper)
[](https://packagist.org/packages/kachit/doctrine-datamapper)
[](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);
```