2016-11-01 13:28:36 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Data\Db;
|
|
|
|
|
|
|
|
|
|
use Icinga\Data\Db\DbConnection as IcingaDbConnection;
|
2022-10-18 10:53:06 -04:00
|
|
|
use Icinga\Module\Director\Db\DbUtil;
|
2021-08-16 00:14:34 -04:00
|
|
|
use RuntimeException;
|
2018-10-30 11:40:17 -04:00
|
|
|
use Zend_Db_Expr;
|
2016-11-01 13:28:36 -04:00
|
|
|
|
|
|
|
|
class DbConnection extends IcingaDbConnection
|
|
|
|
|
{
|
2018-03-28 11:49:59 -04:00
|
|
|
public function isMysql()
|
|
|
|
|
{
|
|
|
|
|
return $this->getDbType() === 'mysql';
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 13:28:36 -04:00
|
|
|
public function isPgsql()
|
|
|
|
|
{
|
|
|
|
|
return $this->getDbType() === 'pgsql';
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-18 10:53:06 -04:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
* @param ?string $binary
|
|
|
|
|
* @return Zend_Db_Expr|Zend_Db_Expr[]|null
|
|
|
|
|
*/
|
2018-10-30 11:40:17 -04:00
|
|
|
public function quoteBinary($binary)
|
|
|
|
|
{
|
2022-10-18 10:53:06 -04:00
|
|
|
return DbUtil::quoteBinaryLegacy($binary, $this->getDbAdapter());
|
2018-10-30 11:40:17 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 00:14:34 -04:00
|
|
|
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
|
|
|
}
|