Db: add idPgsql helper method
This commit is contained in:
parent
f2439412b1
commit
2865efde3f
|
@ -57,7 +57,7 @@ class DeploymentLogTable extends QuickTable
|
|||
'duration' => "l.duration_dump || 'ms'",
|
||||
);
|
||||
|
||||
if ($this->connection->getDbType() === 'pgsql') {
|
||||
if ($this->connection->isPgsql()) {
|
||||
$columns['checksum'] = "LOWER(ENCODE(c.checksum, 'hex'))";
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class GeneratedConfigFileTable extends QuickTable
|
|||
'config_checksum' => 'LOWER(HEX(cf.config_checksum))',
|
||||
);
|
||||
|
||||
if ($this->connection->getDbType() === 'pgsql') {
|
||||
if ($this->connection->isPgsql()) {
|
||||
$columns['checksum'] = "LOWER(ENCODE(f.checksum, 'hex'))";
|
||||
$columns['config_checksum'] = "LOWER(ENCODE(cf.config_checksum, 'hex'))";
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class IcingaHostTable extends IcingaObjectTable
|
|||
|
||||
public function getColumns()
|
||||
{
|
||||
if ($this->connection()->getDbType() === 'pgsql') {
|
||||
if ($this->connection()->isPgsql()) {
|
||||
$parents = "ARRAY_TO_STRING(ARRAY_AGG(ih.object_name ORDER BY hi.weight), ', ')";
|
||||
} else {
|
||||
$parents = "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')";
|
||||
|
|
|
@ -12,7 +12,7 @@ class IcingaZoneTable extends IcingaObjectTable
|
|||
|
||||
public function getColumns()
|
||||
{
|
||||
if ($this->connection()->getDbType() === 'pgsql') {
|
||||
if ($this->connection()->isPgsql()) {
|
||||
$endpoints = "ARRAY_TO_STRING(ARRAY_AGG(e.object_name), ', ')";
|
||||
} else {
|
||||
$endpoints = "GROUP_CONCAT(e.object_name ORDER BY e.object_name SEPARATOR ', ')";
|
||||
|
|
|
@ -629,7 +629,7 @@ abstract class DbObject
|
|||
unset($properties[$this->autoincKeyName]);
|
||||
}
|
||||
// TODO: Remove this!
|
||||
if ($this->connection->getDbType() === 'pgsql') {
|
||||
if ($this->connection->isPgsql()) {
|
||||
foreach ($properties as $key => $value) {
|
||||
if (preg_match('/checksum$/', $key)) {
|
||||
$properties[$key] = Util::pgBinEscape($value);
|
||||
|
@ -688,7 +688,7 @@ abstract class DbObject
|
|||
if ($this->insertIntoDb()) {
|
||||
$id = $this->getId();
|
||||
if ($this->autoincKeyName) {
|
||||
if ($this->connection->getDbType() === 'pgsql') {
|
||||
if ($this->connection->isPgsql()) {
|
||||
$this->properties[$this->autoincKeyName] = $this->db->lastInsertId(
|
||||
$table,
|
||||
$this->autoincKeyName
|
||||
|
|
|
@ -208,7 +208,7 @@ class Db extends DbConnection
|
|||
|
||||
public function fetchActivityLogIdByChecksum($checksum)
|
||||
{
|
||||
if ($this->getDbType() === 'pgsql') {
|
||||
if ($this->isPgsql()) {
|
||||
$checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum));
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ class Db extends DbConnection
|
|||
|
||||
public function fetchActivityLogEntry($checksum)
|
||||
{
|
||||
if ($this->getDbType() === 'pgsql') {
|
||||
if ($this->isPgsql()) {
|
||||
$checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum));
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ class Db extends DbConnection
|
|||
|
||||
public function getLastActivityChecksum()
|
||||
{
|
||||
if ($this->getDbType() === 'pgsql') {
|
||||
if ($this->isPgsql()) {
|
||||
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum"
|
||||
. " FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a"
|
||||
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
|
||||
|
@ -419,7 +419,7 @@ class Db extends DbConnection
|
|||
|
||||
public function getLatestImportedChecksum($source)
|
||||
{
|
||||
if ($this->getDbType() === 'pgsql') {
|
||||
if ($this->isPgsql()) {
|
||||
$col = "LOWER(ENCODE(rowset_checksum, 'hex'))";
|
||||
} else {
|
||||
$col = '(LOWER(HEX(import_run.rowset_checksum)))';
|
||||
|
@ -665,6 +665,11 @@ class Db extends DbConnection
|
|||
return $this->db()->fetchAll($select);
|
||||
}
|
||||
|
||||
public function isPgsql()
|
||||
{
|
||||
return $this->getDbType() === 'pgsql';
|
||||
}
|
||||
|
||||
public function getUncollectedDeployments()
|
||||
{
|
||||
$db = $this->db();
|
||||
|
|
|
@ -186,7 +186,7 @@ class IcingaConfig
|
|||
|
||||
protected function dbBin($binary)
|
||||
{
|
||||
if ($this->connection->getDbType() === 'pgsql') {
|
||||
if ($this->connection->isPgsql()) {
|
||||
return Util::pgBinEscape($binary);
|
||||
} else {
|
||||
return $binary;
|
||||
|
|
Loading…
Reference in New Issue