2017 © Pedro Peláez
 

library mappa

A simple object mapper for PDO

image

atijust/mappa

A simple object mapper for PDO

  • Tuesday, September 15, 2015
  • by atijust
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Mappa

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

Mappa is a simple object mapper for PDO., (*2)

$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [Mappa\Statement::class, [new Mappa\Hydrator()]]);

$stmt = $pdo->prepare("SELECT *, books.name || ' - ' || categories.name AS title FROM books JOIN categories ON categories.id = books.category_id WHERE books.id = ?");

echo get_class($stmt);
// Mappa\Statement

$stmt->execute([1]);

var_export($stmt->hydrate([Book::class, Category::class]));
// array (
//   'books' =>
//   Book::__set_state(array(
//      'id' => '1',
//      'name' => 'B01',
//      'category_id' => '1',
//   )),
//   'categories' =>
//   Category::__set_state(array(
//      'id' => '1',
//      'name' => 'C01',
//   )),
//   '' =>
//   stdClass::__set_state(array(
//      'title' => 'B01 - C01',
//   )),
// )

Mappa works with PHP 5.5 or later., (*3)

TODO

  • Improve error handling
  • Pass custom arguments to entity constructor

The Versions

15/09 2015

dev-master

9999999-dev

A simple object mapper for PDO

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar atijust

orm database pdo