@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class LiskRawMigrationIterator extends PhutilBufferedIterator {
4
5 private $conn;
6 private $table;
7 private $cursor;
8 private $column = 'id';
9
10 public function __construct(AphrontDatabaseConnection $conn, $table) {
11 $this->conn = $conn;
12 $this->table = $table;
13 }
14
15 protected function didRewind() {
16 $this->cursor = 0;
17 }
18
19 #[\ReturnTypeWillChange]
20 public function key() {
21 return idx($this->current(), $this->column);
22 }
23
24 protected function loadPage() {
25 $page = queryfx_all(
26 $this->conn,
27 'SELECT * FROM %T WHERE %C > %d ORDER BY ID ASC LIMIT %d',
28 $this->table,
29 $this->column,
30 $this->cursor,
31 $this->getPageSize());
32
33 if ($page) {
34 $this->cursor = idx(last($page), $this->column);
35 }
36
37 return $page;
38 }
39
40}