sixacross / vinyl
A relational data mapper library
dev-main
2022-01-25 03:10 UTC
Requires
- php: ^7.1
- atlas/info: ^1.2
- atlas/query: ^1.2
- aura/sqlschema: ^2.0
- doctrine/dbal: ^2.9
Requires (Dev)
- ext-sqlite3: *
- phpunit/phpunit: ^7.0
- robmorgan/phinx: ^0.10.8
This package is not auto-updated.
Last update: 2025-03-04 17:54:06 UTC
README
A relational data mapper library
Usage
A brief demo of how to use RecordStores (the repository/mapper) and Records (the entity/model) to CRUD data.
use PDO;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Configuration;
use SixAcross\Vinyl\V1 as Vinyl;
$pdo = new PDO( mysql:dbname=vinyl', 'vinyl', 'some_password' );
$connection = DriverManager::getConnection( [ 'pdo' => $pdo, ], new Configuration );
// see Vinyl\V1\RecordStore for the full interface
$user_store = new Vinyl\RecordStore\SQL\PDO\Doctrine(
'users',
$connection->createQueryBuilder(),
new Vinyl\RecordProducer\PDO\Statement( new Vinyl\Record\Generic )
);
// see Vinyl\V1\Record for the full interface
$user = $user_store->insertRecord([ 'first_name' => 'June', 'last_name' => 'Roderick', ]);
$user = $user_store->getRecord( 99 );
$user['last_name'] = 'Rodriguez';
$user_store->updateRecord( $user );
$user_store->deleteRecord( $user );