code beautifier
This commit is contained in:
@@ -30,21 +30,21 @@ class Connection
|
||||
if (is_dir($config)) {
|
||||
$this->loadEnv($config);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->initPdo();
|
||||
}
|
||||
|
||||
private function parseArray($config)
|
||||
{
|
||||
try {
|
||||
$key = (strtolower(trim($this->name)));
|
||||
$key = (strtolower(trim($this->name)));
|
||||
$this->type = isset($config[$key]["TYPE"]) ? $config[$key]["TYPE"] : null;
|
||||
$this->user = isset($config[$key]["USER"]) ? $config[$key]["USER"] : null;
|
||||
$this->host = isset($config[$key]["HOST"]) ? $config[$config[$key]["HOST"]] : null;
|
||||
$this->password = isset($config[$key]["PASSWORD"]) ? $config[$key]["PASSWORD"] : null;
|
||||
$this->database = isset($config[$key]["DATABASE"]) ? $config[$key]["DATABASE"] : null;
|
||||
$this->port = isset($config[$key]["PORT"]) ? $config[$key]["PORT"] : null;
|
||||
} catch (\Throwable $th) {
|
||||
} catch (\Throwable $th) {
|
||||
$this->error = $th->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -172,21 +172,20 @@ class Connection
|
||||
if (!isset(self::$instances[$connection])) {
|
||||
self::$instances[$connection] = new Connection($connection, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance($connection="")
|
||||
{
|
||||
if($connection=="" && count(self::$instances)>0)
|
||||
{
|
||||
public static function getInstance($connection = "")
|
||||
{
|
||||
if ($connection == "" && count(self::$instances) > 0) {
|
||||
$connection = array_keys(self::$instances)[0];
|
||||
}
|
||||
}
|
||||
if (isset(self::$instances[$connection])) {
|
||||
$instance = self::$instances[$connection];
|
||||
if ($instance instanceof Connection) {
|
||||
return self::$instances[$connection];
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new \Exception("Unknown connection");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ class Model
|
||||
protected array $updated;
|
||||
protected string $table;
|
||||
protected string $connection = "";
|
||||
protected string $pk;
|
||||
protected string $pk;
|
||||
private bool $new;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
{
|
||||
$this->new = true;
|
||||
$this->values = array();
|
||||
$this->updated = array();
|
||||
@@ -62,7 +62,7 @@ class Model
|
||||
}
|
||||
|
||||
public function save(): bool
|
||||
{
|
||||
{
|
||||
$ret = false;
|
||||
$qb = $this->newQueryBuilder();
|
||||
if ($this->new) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Kletellier\PdoWrapper;
|
||||
|
||||
class QueryBuilder
|
||||
{
|
||||
{
|
||||
protected array $columns;
|
||||
protected array $wheres;
|
||||
protected array $orders;
|
||||
@@ -20,7 +20,7 @@ class QueryBuilder
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->pk = $pk;
|
||||
$this->connection = $connection;
|
||||
$this->connection = $connection;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ class QueryBuilder
|
||||
}
|
||||
|
||||
private function getData(): mixed
|
||||
{
|
||||
{
|
||||
return Connection::getInstance($this->connection)->getSelectQuery($this->getQuery());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user