mittnett/dbal

一个非常简单的数据库抽象层。底层使用PDO,支持mysql/mariadb和postgres。

v1.4.2 2022-10-15 21:10 UTC

This package is auto-updated.

Last update: 2024-09-16 01:43:20 UTC


README

一个非常简单的数据库抽象层。底层使用PDO,支持mysql/mariadb和postgres。

使用方法

设置连接

<?php

// MySQL:
$db = new \HbLib\DBAL\DatabaseConnection(new PDO('mysql:host=localhost;dbname=app', 'app', 'secret'), new \HbLib\DBAL\Driver\MySQLDriver());

// Postgres:
$db = new \HbLib\DBAL\DatabaseConnection(new PDO('pgsql:host=localhost;dbname=app', 'app', 'secret'), new \HbLib\DBAL\Driver\PostgresDriver());

可以使用\HbLib\DBAL\LazyDatabaseConnection,它只在需要时创建PDO连接。