fix: Определения типов
This commit is contained in:
parent
9f6fd74b17
commit
dd74a97894
28 changed files with 334 additions and 249 deletions
|
|
@ -31,7 +31,8 @@ namespace ctiso {
|
|||
|
||||
function prepare(string $sql, array $options = []): PDOStatement|false
|
||||
{
|
||||
$result/*: PDOStatement*/ = parent::prepare($sql, $options);
|
||||
/** @var PDOStatement $result */
|
||||
$result = parent::prepare($sql, $options);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -49,10 +50,11 @@ namespace ctiso {
|
|||
static function getConnection(array $dsn)
|
||||
{
|
||||
|
||||
/** @var ?Database */
|
||||
$connection = null;
|
||||
if ($dsn['phptype'] == 'pgsql' || $dsn['phptype'] == 'mysql') {
|
||||
$port = (isset($dsn['port'])) ? "port={$dsn['port']};" : "";
|
||||
$connection/*: Database*/ = new self("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']);
|
||||
$connection = new self("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']);
|
||||
if ($dsn['phptype'] == 'pgsql') {
|
||||
$connection->query('SET client_encoding="UTF-8"');
|
||||
}
|
||||
|
|
@ -64,9 +66,9 @@ namespace ctiso {
|
|||
$connection = new self("{$dsn['phptype']}:");
|
||||
$connection->sqliteCreateFunction('LOWER', 'sqliteLower', 1);
|
||||
} elseif ($dsn['phptype'] == 'sqlite') {
|
||||
$connection/*: Database*/ = new self("{$dsn['phptype']}:{$dsn['database']}");
|
||||
$connection = new self("{$dsn['phptype']}:{$dsn['database']}");
|
||||
$connection->setAttribute(PDO::ATTR_TIMEOUT, 5);
|
||||
$mode = defined('SQLITE_JOURNAL_MODE') ? SQLITE_JOURNAL_MODE : 'WAL';
|
||||
$mode = defined('SQLITE_JOURNAL_MODE') ? \SQLITE_JOURNAL_MODE : 'WAL';
|
||||
$connection->query("PRAGMA journal_mode=$mode");
|
||||
$connection->sqliteCreateFunction('LOWER', 'sqliteLower', 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue