2019-01-12 17:43:06 +00:00
|
|
|
<?php
|
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2021-04-14 15:17:01 +00:00
|
|
|
|
2019-08-25 17:19:11 +00:00
|
|
|
namespace JKingWeb\Arsse\Test\DatabaseDrivers;
|
2019-01-12 17:43:06 +00:00
|
|
|
|
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
|
|
|
|
trait PostgreSQL {
|
2022-01-11 22:54:02 +00:00
|
|
|
use PostgreSQLCommon;
|
|
|
|
|
2019-01-12 17:43:06 +00:00
|
|
|
protected static $implementation = "PostgreSQL";
|
|
|
|
protected static $backend = "PostgreSQL";
|
|
|
|
protected static $dbResultClass = \JKingWeb\Arsse\Db\PostgreSQL\Result::class;
|
|
|
|
protected static $dbStatementClass = \JKingWeb\Arsse\Db\PostgreSQL\Statement::class;
|
|
|
|
protected static $dbDriverClass = \JKingWeb\Arsse\Db\PostgreSQL\Driver::class;
|
|
|
|
protected static $stringOutput = true;
|
2020-03-01 20:16:50 +00:00
|
|
|
|
2019-01-12 17:43:06 +00:00
|
|
|
public static function dbInterface() {
|
|
|
|
$connString = \JKingWeb\Arsse\Db\PostgreSQL\Driver::makeConnectionString(false, Arsse::$conf->dbPostgreSQLUser, Arsse::$conf->dbPostgreSQLPass, Arsse::$conf->dbPostgreSQLDb, Arsse::$conf->dbPostgreSQLHost, Arsse::$conf->dbPostgreSQLPort, "");
|
2020-10-30 16:16:03 +00:00
|
|
|
if (function_exists("pg_connect") && $d = @pg_connect($connString, \PGSQL_CONNECT_FORCE_NEW)) {
|
2019-01-12 17:43:06 +00:00
|
|
|
foreach (\JKingWeb\Arsse\Db\PostgreSQL\Driver::makeSetupQueries(Arsse::$conf->dbPostgreSQLSchema) as $q) {
|
|
|
|
pg_query($d, $q);
|
|
|
|
}
|
|
|
|
return $d;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|