thephpeffect/connection-manager

PHP中任何面向对象数据库连接的简单连接管理器

v1.0 2015-09-23 00:05 UTC

This package is not auto-updated.

Last update: 2024-09-26 00:44:26 UTC


README

一个PHP单例,用于跟踪多个数据库连接。

安装

推荐通过composer(https://getcomposer.org/)安装ConnectionManager。在您的shell环境中输入以下命令

php ~/composer.phar require thephpeffect/connection-manager

用法

可以通过不传递连接名称的方式使用db()函数访问"默认"连接。

db("default", new mysqli(...));
db("stats", new PDO(...));

$result = db()->query("SELECT * FROM table1");
$statement = db("stats")->prepare("SELECT * FROM table1 WHERE a=? AND b=?");