Files
InverleandAlexandre Alapetite a84c0a8bc2 Fix all broken links in the entire repository (#9207)
* Fix all broken links in the entire repository

* Update docs/CHANGELOG-old2.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update config.default.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update README.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update docs/i18n/freshrss.fr.po

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update docs/i18n/templates/freshrss.pot

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update README.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update docs/fr/users/01_Installation.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update docs/fr/users/01_Installation.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update docs/en/internationalization.md

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Manual fixes, preferences
* Prefer canonical when known, prefer shorter, prefer roots, prefer URLs with content negotation (e.g. language preference)
* Keep 302, 307 unchanged
* Use only `.example`, `example.net` or similarly reserved domains for URL examples

* Fix language negotiation for developer.mozilla.org

* Restore a Stackoverflow 302

* Fix some example.com

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-08-19 16:19:21 +02:00

80 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
/**
* MINZ - Copyright 2011 Marien Fressinaud
* Sous licence 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, ?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);
}
}