Files
FreshRSS/lib/Minz/Pdo.php
T
Inverle 0addf32b36 Translate non-English code comments and identifiers (#9383)
Note: The changes in this PR are entirely AI-authored but manually reviewed and tested

## Summary

Translate the remaining French prose and French-derived identifiers in the main FreshRSS/Minz codebase to English.

Why: helps to understand the code

## Scope

- Minz comments, PHPDoc, and paginator identifiers
- Application comments and related identifiers
- Installer database identifiers
- Theme metadata descriptions and the identified CSS comments, previous discussion: https://github.com/FreshRSS/FreshRSS/pull/8241#discussion_r2553181653
- Related call sites and view helpers

External libraries and intentional i18n/docs content are excluded.
2026-10-20 09:52:31 +02:00

80 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
/**
* MINZ - Copyright 2011 Marien Fressinaud
* Licensed under AGPL3 <https://www.gnu.org/licenses/>
*/
abstract class Minz_Pdo extends PDO {
/**
* @param array<int,int|string|bool>|null $options
* @throws PDOException
*/
public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $passwd = null, ?array $options = null) {
parent::__construct($dsn, $username, $passwd, $options);
$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
abstract public function dbType(): string;
private string $prefix = '';
public function prefix(): string {
return $this->prefix;
}
public function setPrefix(string $prefix): void {
$this->prefix = $prefix;
}
private function autoPrefix(string $sql): string {
return str_replace('`_', '`' . $this->prefix, $sql);
}
protected function preSql(string $statement): string {
if (preg_match('/^(?:UPDATE|INSERT|DELETE)/i', $statement) === 1) {
invalidateHttpCache();
}
return $this->autoPrefix($statement);
}
/**
* @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
*/
#[\Override]
public function lastInsertId(?string $name = null): string|false {
if ($name != null) {
$name = $this->preSql($name);
}
return parent::lastInsertId($name);
}
/**
* @param array<int,string> $options
* @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
* @phpstan-ignore method.childParameterType
*/
#[\Override]
public function prepare(string $query, array $options = []): PDOStatement|false {
$query = $this->preSql($query);
return parent::prepare($query, $options);
}
/**
* @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
*/
#[\Override]
public function exec(string $statement): int|false {
$statement = $this->preSql($statement);
return parent::exec($statement);
}
/**
* @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
*/
#[\Override]
public function query(string $query, ?int $fetch_mode = null, ...$fetch_mode_args): PDOStatement|false {
$query = $this->preSql($query);
return $fetch_mode === null ? parent::query($query) : parent::query($query, $fetch_mode, ...$fetch_mode_args);
}
}