Skip to content
Snippets Groups Projects
Verified Commit 957c87e7 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

feat: :guitar: Make methods for reading DB public

make methods to read and related tasks for constructing read queries
public so other components can make use of it (i.e. external API that
needs to use custom query)
parent e28d4acf
No related branches found
No related tags found
1 merge request!84feat: 🎸 Make methods for reading DB public
......@@ -242,6 +242,34 @@ class DatabaseCommand
}
}
public function read($query, $params): PDOStatement
{
return $this->conn->read($query, $params);
}
public function isPgsql(): bool
{
return $this->conn->getDriver() === 'pgsql';
}
public function isMysql(): bool
{
return $this->conn->getDriver() === 'mysql';
}
public function escapeCol($col_name): string
{
return $this->escape_char . $col_name . $this->escape_char;
}
public function escapeCols($col_names): string
{
return $this->escape_char . implode(
$this->escape_char . ',' . $this->escape_char,
$col_names
) . $this->escape_char;
}
private function insertLogin($entities, $userId, $date)
{
foreach (Config::SIDES as $side) {
......@@ -265,11 +293,6 @@ class DatabaseCommand
}
}
private function escapeCol($col_name): string
{
return $this->escape_char . $col_name . $this->escape_char;
}
private function writeLogin($date, $ids, $user): bool
{
if (empty($user)) {
......@@ -475,14 +498,6 @@ class DatabaseCommand
return ':' . $str;
}
private function escapeCols($col_names): string
{
return $this->escape_char . implode(
$this->escape_char . ',' . $this->escape_char,
$col_names
) . $this->escape_char;
}
private function getAggregateGroupBy($ids): string
{
$columns = ['day'];
......@@ -532,21 +547,6 @@ class DatabaseCommand
return $displayName;
}
private function read($query, $params): PDOStatement
{
return $this->conn->read($query, $params);
}
private function isPgsql(): bool
{
return $this->conn->getDriver() === 'pgsql';
}
private function isMysql(): bool
{
return $this->conn->getDriver() === 'mysql';
}
private function unknownDriver()
{
Logger::error(self::DEBUG_PREFIX . 'unsupported DB driver \'' . $this->conn->getDriver());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment