mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 07:34:55 +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) {
|
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;
|
if(!$row) return null;
|
||||||
switch($row['type']) {
|
switch($row['type']) {
|
||||||
case "int": return (int) $row['value'];
|
case "int": return (int) $row['value'];
|
||||||
|
@ -218,7 +218,7 @@ class Database {
|
||||||
|
|
||||||
public function userPropertiesGet(string $user): array {
|
public function userPropertiesGet(string $user): array {
|
||||||
if(!$this->data->user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
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 [];
|
if(!$prop) return [];
|
||||||
return $prop;
|
return $prop;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ class Database {
|
||||||
$root = null;
|
$root = null;
|
||||||
} else {
|
} 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
|
// 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) {
|
if($p===null) {
|
||||||
throw new Db\ExceptionInput("idMissing", ["action" => __FUNCTION__, "field" => "parent", 'id' => $parent]);
|
throw new Db\ExceptionInput("idMissing", ["action" => __FUNCTION__, "field" => "parent", 'id' => $parent]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,7 @@ interface Result extends \Iterator {
|
||||||
function rewind();
|
function rewind();
|
||||||
function valid();
|
function valid();
|
||||||
|
|
||||||
function get();
|
function getRow();
|
||||||
function getAll();
|
function getAll();
|
||||||
function getValue();
|
function getValue();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Result implements \JKingWeb\NewsSync\Db\Result {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get() {
|
public function getRow() {
|
||||||
$this->next();
|
$this->next();
|
||||||
return ($this->valid() ? $this->cur : null);
|
return ($this->valid() ? $this->cur : null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,9 @@ class TestDbResultSQLite3 extends \PHPUnit\Framework\TestCase {
|
||||||
['album' => 'Clockwork Angels', 'track' => 'The Wreckers'],
|
['album' => 'Clockwork Angels', 'track' => 'The Wreckers'],
|
||||||
];
|
];
|
||||||
$test = new Db\SQLite3\Result($set);
|
$test = new Db\SQLite3\Result($set);
|
||||||
$this->assertEquals($rows[0], $test->get());
|
$this->assertEquals($rows[0], $test->getRow());
|
||||||
$this->assertEquals($rows[1], $test->get());
|
$this->assertEquals($rows[1], $test->getRow());
|
||||||
$this->assertSame(null, $test->get());
|
$this->assertSame(null, $test->getRow());
|
||||||
$this->assertEquals($rows, $test->getAll());
|
$this->assertEquals($rows, $test->getAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
||||||
$types = array_unique(Statement::TYPES);
|
$types = array_unique(Statement::TYPES);
|
||||||
foreach($types as $type) {
|
foreach($types as $type) {
|
||||||
$s->rebindArray([$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.");
|
$this->assertSame($expectations[$type], $val, "Type $type failed comparison.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
||||||
function testBindMissingValue() {
|
function testBindMissingValue() {
|
||||||
$nativeStatement = $this->c->prepare("SELECT ? as value");
|
$nativeStatement = $this->c->prepare("SELECT ? as value");
|
||||||
$s = new self::$imp($this->c, $nativeStatement);
|
$s = new self::$imp($this->c, $nativeStatement);
|
||||||
$val = $s->runArray()->get()['value'];
|
$val = $s->runArray()->getRow()['value'];
|
||||||
$this->assertSame(null, $val);
|
$this->assertSame(null, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
|
||||||
];
|
];
|
||||||
$nativeStatement = $this->c->prepare("SELECT ? as one, ? as two");
|
$nativeStatement = $this->c->prepare("SELECT ? as one, ? as two");
|
||||||
$s = new self::$imp($this->c, $nativeStatement, ["int", "int"]);
|
$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);
|
$this->assertSame($exp, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue