BREAKING CHANGE: Adhere to PSR-12 coding standards.
- Model: where_in method was renamed as whereIn.
This commit is contained in:
@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Libs;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
|
||||
/**
|
||||
* Database - DuckBrain
|
||||
*
|
||||
@ -8,38 +15,33 @@
|
||||
* @website https://kj2.me
|
||||
* @licence MIT
|
||||
*/
|
||||
class Database extends PDO
|
||||
{
|
||||
private static array $databases = [];
|
||||
|
||||
namespace Libs;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Exception;
|
||||
|
||||
class Database extends PDO {
|
||||
static private array $databases = [];
|
||||
|
||||
private function __construct() {}
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve una instancia homogénea (singlenton) de la base de datos (PDO).
|
||||
*
|
||||
* @return PDO
|
||||
*/
|
||||
static public function getInstance(
|
||||
public static function getInstance(
|
||||
string $type = 'mysql',
|
||||
string $host = 'localhost',
|
||||
string $name = '',
|
||||
string $user = '',
|
||||
string $pass = '',
|
||||
): PDO
|
||||
{
|
||||
$key = $type.'/'.$host.'/'.$name.'/'.$user;
|
||||
): PDO {
|
||||
$key = $type . '/' . $host . '/' . $name . '/' . $user;
|
||||
if (empty(static::$databases[$key])) {
|
||||
|
||||
if ($type == 'sqlite') {
|
||||
$dsn = $type .':'. $name;
|
||||
} else
|
||||
$dsn = $type.':dbname='.$name.';host='.$host;
|
||||
$dsn = $type . ':' . $name;
|
||||
} else {
|
||||
$dsn = $type . ':dbname=' . $name . ';host=' . $host;
|
||||
}
|
||||
|
||||
try {
|
||||
static::$databases[$key] = new PDO($dsn, $user, $pass);
|
||||
@ -55,4 +57,3 @@ class Database extends PDO {
|
||||
return static::$databases[$key];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user