gossamer/pesedget

PHP 数据库实体管理器

2.0.0 2017-03-18 02:37 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:33:14 UTC


README

PHP 数据库实体管理器

最初作为 GossamerCMS 框架内的实体管理器而设计。这允许从单个配置文件配置多个数据源,并通过实体管理器的 Key 请求它们。它通过自己的引导程序抽象配置的加载,因此一个方法可以在软件的任何位置调用实体管理器中的连接,而无需担心它是否已经实例化,以及其所需的凭据是什么。

实体管理器是单例模式。要调用它

$manager = EntityManager::getInstance(); $connection = $manager->getConnection(); //默认连接

您可以通过名称指定单个连接

$mysqlConnection = $manager->getConnection('mysql'); $mssqlConnection = $manager->getConnection('mssql');

yml 凭据的格式如下

数据库
----mysql
--------class: 'Gossamer\Pesedget\Database\DBConnection'
--------credentials
-----------host: localhost
-----------username: user_id
-----------password: isnothere
-----------dbName: db_name_here

#tell the EM which connection to use if no key specified          

----default: mysql

为什么叫 Pesedget?

Pesedget 是埃及众神之一的一组实体。.... 实体组...谢谢...试试排骨...