Skip to content

Commit

Permalink
modify the 'use' method name to avoid reserved wrds
Browse files Browse the repository at this point in the history
  • Loading branch information
Link1515 committed Mar 26, 2024
1 parent 6079749 commit e13a7eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
```

Expand Down
4 changes: 2 additions & 2 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down

0 comments on commit e13a7eb

Please sign in to comment.