icingaweb2-module-director/library/Director/Data/Db/DbConnection.php

52 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2016-11-01 13:28:36 -04:00
<?php
namespace Icinga\Module\Director\Data\Db;
use Icinga\Data\Db\DbConnection as IcingaDbConnection;
use Icinga\Module\Director\Db\DbUtil;
use RuntimeException;
use Zend_Db_Expr;
2016-11-01 13:28:36 -04:00
class DbConnection extends IcingaDbConnection
{
public function isMysql()
{
return $this->getDbType() === 'mysql';
}
2016-11-01 13:28:36 -04:00
public function isPgsql()
{
return $this->getDbType() === 'pgsql';
}
/**
* @deprecated
* @param ?string $binary
* @return Zend_Db_Expr|Zend_Db_Expr[]|null
*/
public function quoteBinary($binary)
{
return DbUtil::quoteBinaryLegacy($binary, $this->getDbAdapter());
}
public function binaryDbResult($value)
{
if (is_resource($value)) {
return stream_get_contents($value);
}
return $value;
}
2016-11-01 13:28:36 -04:00
public function hasPgExtension($name)
{
$db = $this->db();
$query = $db->select()->from(
array('e' => 'pg_extension'),
array('cnt' => 'COUNT(*)')
)->where('extname = ?', $name);
return (int) $db->fetchOne($query) === 1;
}
2017-01-13 13:47:54 -05:00
}