mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Rename Result->get() to Result->getRow
It should be slightly clearer what it does
This commit is contained in:
parent
bdf3182305
commit
485400df2b
5 changed files with 11 additions and 11 deletions
|
@ -52,7 +52,7 @@ class Database {
|
|||
}
|
||||
|
||||
public function settingGet(string $key) {
|
||||
$row = $this->db->prepare("SELECT value, type from newssync_settings where key = ?", "str")->run($key)->get();
|
||||
$row = $this->db->prepare("SELECT value, type from newssync_settings where key = ?", "str")->run($key)->getRow();
|
||||
if(!$row) return null;
|
||||
switch($row['type']) {
|
||||
case "int": return (int) $row['value'];
|
||||
|
@ -218,7 +218,7 @@ class Database {
|
|||
|
||||
public function userPropertiesGet(string $user): array {
|
||||
if(!$this->data->user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||
$prop = $this->db->prepare("SELECT name,rights from newssync_users where id is ?", "str")->run($user)->get();
|
||||
$prop = $this->db->prepare("SELECT name,rights from newssync_users where id is ?", "str")->run($user)->getRow();
|
||||
if(!$prop) return [];
|
||||
return $prop;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ class Database {
|
|||
$root = null;
|
||||
} else {
|
||||
// if a parent is specified, make sure it exists and belongs to the user; get its root (first-level) folder if it's a nested folder
|
||||
$p = $this->db->prepare("SELECT id,root from newssync_folders where owner is ? and id is ?", "str", "int")->run($user, $parent)->get();
|
||||
$p = $this->db->prepare("SELECT id,root from newssync_folders where owner is ? and id is ?", "str", "int")->run($user, $parent)->getRow();
|
||||
if($p===null) {
|
||||
throw new Db\ExceptionInput("idMissing", ["action" => __FUNCTION__, "field" => "parent", 'id' => $parent]);
|
||||
} else {
|
||||
|
|
|
@ -9,7 +9,7 @@ interface Result extends \Iterator {
|
|||
function rewind();
|
||||
function valid();
|
||||
|
||||
function get();
|
||||
function getRow();
|
||||
function getAll();
|
||||
function getValue();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Result implements \JKingWeb\NewsSync\Db\Result {
|
|||
return null;
|
||||
}
|
||||
|
||||
public function get() {
|
||||
public function getRow() {
|
||||
$this->next();
|
||||
return ($this->valid() ? $this->cur : null);
|
||||
}
|
||||
|
|
|
@ -81,9 +81,9 @@ class TestDbResultSQLite3 extends \PHPUnit\Framework\TestCase {
|
|||
['album' => 'Clockwork Angels', 'track' => 'The Wreckers'],
|
||||
];
|
||||
$test = new Db\SQLite3\Result($set);
|
||||
$this->assertEquals($rows[0], $test->get());
|
||||
$this->assertEquals($rows[1], $test->get());
|
||||
$this->assertSame(null, $test->get());
|
||||
$this->assertEquals($rows[0], $test->getRow());
|
||||
$this->assertEquals($rows[1], $test->getRow());
|
||||
$this->assertSame(null, $test->getRow());
|
||||
$this->assertEquals($rows, $test->getAll());
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
|||
$types = array_unique(Statement::TYPES);
|
||||
foreach($types as $type) {
|
||||
$s->rebindArray([$type]);
|
||||
$val = $s->runArray([$input])->get()['value'];
|
||||
$val = $s->runArray([$input])->getRow()['value'];
|
||||
$this->assertSame($expectations[$type], $val, "Type $type failed comparison.");
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
|||
function testBindMissingValue() {
|
||||
$nativeStatement = $this->c->prepare("SELECT ? as value");
|
||||
$s = new self::$imp($this->c, $nativeStatement);
|
||||
$val = $s->runArray()->get()['value'];
|
||||
$val = $s->runArray()->getRow()['value'];
|
||||
$this->assertSame(null, $val);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
|||
];
|
||||
$nativeStatement = $this->c->prepare("SELECT ? as one, ? as two");
|
||||
$s = new self::$imp($this->c, $nativeStatement, ["int", "int"]);
|
||||
$val = $s->runArray([1,2])->get();
|
||||
$val = $s->runArray([1,2])->getRow();
|
||||
$this->assertSame($exp, $val);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue