multi connections system
This commit is contained in:
@@ -4,22 +4,24 @@ namespace Kletellier\PdoWrapper;
|
||||
|
||||
class QueryBuilder
|
||||
{
|
||||
protected Db $db;
|
||||
protected ?Db $db;
|
||||
protected array $columns;
|
||||
protected array $wheres;
|
||||
protected array $orders;
|
||||
protected array $groupby;
|
||||
protected string $table;
|
||||
protected string $connection;
|
||||
protected string $pk;
|
||||
protected ?int $take;
|
||||
protected ?int $offset;
|
||||
protected string $raw_query;
|
||||
|
||||
public function __construct($table, $pk = "id")
|
||||
public function __construct($table, $pk = "id", $connection = "default")
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->pk = $pk;
|
||||
$this->db = Db::getInstance();
|
||||
$this->connection = $connection;
|
||||
$this->db = null;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -175,6 +177,7 @@ class QueryBuilder
|
||||
|
||||
private function getData(): mixed
|
||||
{
|
||||
$this->db = Db::getInstance($this->connection);
|
||||
return $this->db->getSelectQuery($this->getQuery());
|
||||
}
|
||||
|
||||
@@ -265,4 +268,14 @@ class QueryBuilder
|
||||
return $this->getConstructedQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
public function setConnection($connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user