1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 12:31:15 +01:00
This commit is contained in:
Daniil Gentili 2023-05-19 22:19:31 +02:00
parent 14031ce14b
commit 5949b483a5
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 4 additions and 18 deletions

View File

@ -74,17 +74,7 @@ class PostgresArray extends SqlArray
*/
public function initConnection(DatabasePostgres $settings): void
{
$config = PostgresConfig::fromString('host='.\str_replace('tcp://', '', $settings->getUri()));
$host = $config->getHost();
$port = $config->getPort();
$this->pdo = new PDO(
"pgsql:host={$host};port={$port}",
$settings->getUsername(),
$settings->getPassword(),
);
if (!isset($this->db)) {
$this->db = Postgres::getConnection($settings);
}
$this->db ??= Postgres::getConnection($settings);
}
protected function setSerializer(SerializerType $serializer): void
@ -92,8 +82,8 @@ class PostgresArray extends SqlArray
$this->serializer = match ($serializer) {
SerializerType::SERIALIZE => fn ($v) => new ByteA(\serialize($v)),
SerializerType::IGBINARY => fn ($v) => new ByteA(\igbinary_serialize($v)),
SerializerType::JSON => fn ($value) => \json_encode($value, JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES),
SerializerType::STRING => strval(...),
SerializerType::JSON => fn ($v) => new ByteA(\json_encode($v, JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES)),
SerializerType::STRING => fn ($v) => new ByteA(strval($v)),
};
$this->deserializer = match ($serializer) {
SerializerType::SERIALIZE => \unserialize(...),

View File

@ -75,11 +75,7 @@ abstract class SqlArray extends DriverArray
return $this->getCache($key);
}
$row = $this->execute($this->queries[self::SQL_GET], ['index' => $key]);
/*if (!$row->getRowCount()) {
return null;
}*/
$row = $row->fetchRow();
$row = $this->execute($this->queries[self::SQL_GET], ['index' => $key])->fetchRow();
if ($row === null) {
return null;
}