Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/storage/lisk/LiskRawMigrationIterator.php
12242 views
1
<?php
2
3
final 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
public function key() {
20
return idx($this->current(), $this->column);
21
}
22
23
protected function loadPage() {
24
$page = queryfx_all(
25
$this->conn,
26
'SELECT * FROM %T WHERE %C > %d ORDER BY ID ASC LIMIT %d',
27
$this->table,
28
$this->column,
29
$this->cursor,
30
$this->getPageSize());
31
32
if ($page) {
33
$this->cursor = idx(last($page), $this->column);
34
}
35
36
return $page;
37
}
38
39
}
40
41