mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 09:02:41 +00:00
42a5ccb96c
Queries for multiple specific articles are limited in size because of limits on the number of bound query parameters. Currently this limit is somewhat arbitrarily set at 50, but it may increase. Historically controllers would be responsible for chunking input, but this will present problems when the expected output is a result set, and of course the maintenance burden increases as the number of controllers increases. This commit transfers the burden to the data model, and consequently introduces a ResultAggregate class which collects chunked result sets (currently only for articleList). In the course of making these changes the mock Result class was also largely rewritten, fixing many bugs with it. This commit does not modify the controllers nor their tests; this will be done in a subsequent commit.
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\Arsse\Db\SQLite3;
|
|
|
|
use JKingWeb\Arsse\Db\Exception;
|
|
|
|
class Result extends \JKingWeb\Arsse\Db\AbstractResult {
|
|
protected $st;
|
|
protected $set;
|
|
protected $cur = null;
|
|
protected $rows = 0;
|
|
protected $id = 0;
|
|
|
|
// actual public methods
|
|
|
|
public function changes() {
|
|
return $this->rows;
|
|
}
|
|
|
|
public function lastId() {
|
|
return $this->id;
|
|
}
|
|
|
|
// constructor/destructor
|
|
|
|
public function __construct(\SQLite3Result $result, array $changes = [0,0], Statement $statement = null) {
|
|
$this->st = $statement; //keeps the statement from being destroyed, invalidating the result set
|
|
$this->set = $result;
|
|
$this->rows = $changes[0];
|
|
$this->id = $changes[1];
|
|
}
|
|
|
|
public function __destruct() {
|
|
try {
|
|
$this->set->finalize();
|
|
} catch (\Throwable $e) { // @codeCoverageIgnore
|
|
}
|
|
unset($this->set);
|
|
}
|
|
|
|
// PHP iterator methods
|
|
|
|
public function valid() {
|
|
$this->cur = $this->set->fetchArray(\SQLITE3_ASSOC);
|
|
return ($this->cur !== false);
|
|
}
|
|
}
|