BREAKING CHANGE: Adhere to PSR-12 coding standards.

- Model: where_in method was renamed as whereIn.
This commit is contained in:
kj
2025-09-07 11:07:07 -03:00
parent 0f46848d15
commit c9f467345b
10 changed files with 480 additions and 401 deletions

View File

@ -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];
}
}
?>