Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 795 Bytes

DB-CLASS.md

File metadata and controls

50 lines (35 loc) · 795 Bytes

Db class

This class is also a bonus. It serves as a building block for the mapper but can be used by itself:

$db = new Db(new Pdo('sqlite:mydb.sq3'));

Raw stdClass:

$db->select('*')->from('author')->fetchAll();

Custom class:

$db->select('*')->from('author')->fetchAll('MyAuthorClass');

Into existing object:

$db->select('*')->from('author')->limit(1)->fetch($alexandre);

Array:

$db->select('*')->from('author')->fetchAll(array());

Callback:

$db->select('*')->from('author')->fetchAll(function($obj) {
    return AuthorFactory::create((array) $obj);
});

See also: