codin / dbal
Table Gateway pattern wrapper for Doctrine DBAL
dev-master
2021-07-10 06:03 UTC
Requires
- php: >=7.4
- doctrine/dbal: ^3|^2
Requires (Dev)
- friends-of-phpspec/phpspec-code-coverage: @stable
- friendsofphp/php-cs-fixer: @stable
- phpspec/phpspec: @stable
- phpstan/phpstan: @stable
This package is auto-updated.
Last update: 2024-10-10 12:55:53 UTC
README
This is not a full orm, this is only a tribute.
Usage
class Product { protected string $uuid; protected string $desc; public function getUuid(): string { return $this->uuid; } public function getDesc(): string { return $this->desc; } } class Products extends Codin\DBAL\TableGateway { protected string $table = 'products'; protected string $primary = 'uuid'; protected string $model = Product::class; } $conn = new Doctrine\DBAL\Connection(['pdo' => new PDO('sqlite:products.db')]); $conn->exec('create table if not exists products (uuid string, desc string)'); $products = new Products($conn); $products->insert(['desc' => 'banana', 'uuid' => 'BAN01']); $banana = $products->fetch(); echo $product->getDesc(); // "banana"