From e13a7ebef501f45e1ae1a8bba58d568d23e9fee1 Mon Sep 17 00:00:00 2001 From: Link1515 Date: Tue, 26 Mar 2024 15:08:36 +0800 Subject: [PATCH] modify the 'use' method name to avoid reserved wrds --- README.md | 6 +++--- src/DB.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 99f9915..31d522e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ use Link1515\DbUtilsPhp5\DB; DB::connect(string $id, string $drive, string $host, string $database, string $user, string $password): void; // Use the database with the specified id. -DB::use(string $id): void; +DB::useConnection(string $id): void; // Get the PDO with the specified id. If no id is passed, the default connection PDO will be returned. DB::PDO(?string $id): PDO; @@ -64,10 +64,10 @@ Multiple connection: DB::connect('conn_1', 'mysql', 'localhost:3306', 'shop', 'root', 'root'); DB::connect('conn_2', 'mysql', 'localhost:3306', 'app', 'root', 'root'); -DB::use('conn_1'); +DB::useConnection('conn_1'); BaseORM::createForTable('orders', ['user_id' => 1, 'price' => 100]); -DB::use('conn_2'); +DB::useConnection('conn_2'); BaseORM::getAllForTable('user'); ``` diff --git a/src/DB.php b/src/DB.php index c6a7b0b..0e8be90 100644 --- a/src/DB.php +++ b/src/DB.php @@ -59,7 +59,7 @@ public static function connect($id, $driver, $host, $database, $user, $passwd) * * @param string $id */ - public static function use($id) + public static function useConnection($id) { if (!isset (self::$pdoList[$id])) { throw new \RuntimeException('PDO with ID "' . $id . '" does not exist'); @@ -79,7 +79,7 @@ public static function use($id) public static function PDO($id = null) { if (isset ($id)) { - self::use($id); + self::useConnection($id); } return self::$currentPdo;