Files
FreshRSS/app/Models/CategoryDAOSQLite.php
Alexandre Alapetite aeb55693e4 SQL improve PHP syntax uniformity (#8604)
* New SQL wrapper function `fetchInt()`
* Favour use of `fetchAssoc()`, `fetchInt()`, `fetchColumn()`
* Favour Nowdoc / Heredoc syntax for SQL
    * Update indenting to PHP 8.1+ convention
* Favour `bindValue()` instead of position `?` when possible
* Favour `bindValue()` over `bindParam()`
* More uniform and robust syntax when using `bindValue()`, checking return code
2026-03-15 14:44:39 +01:00

34 lines
979 B
PHP

<?php
declare(strict_types=1);
class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO {
#[\Override]
public function sqlResetSequence(): bool {
return true; // Nothing to do for SQLite
}
/** @param array{0:string,1:int,2:string} $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {
if (isset($errorInfo[0])) {
$errorLines = explode("\n", $errorInfo[2], 2); // The relevant column name is on the first line, other lines are noise
if (str_contains($errorLines[0], 'f.')) { // Coming from a feed sub-query
$feedDao = FreshRSS_Factory::createFeedDao();
if ($feedDao->autoUpdateDb($errorInfo)) {
return true;
}
}
}
$columns = $this->fetchColumn("PRAGMA table_info('category')", 1);
if ($columns !== null) {
foreach (['kind', 'lastUpdate', 'error', 'attributes'] as $column) {
if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
}
}
}
return false;
}
}