diff --git a/lib/Database.php b/lib/Database.php index e7336fe3..fb3356dd 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -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 { diff --git a/lib/Db/Result.php b/lib/Db/Result.php index 0f853f7f..b08741d5 100644 --- a/lib/Db/Result.php +++ b/lib/Db/Result.php @@ -9,7 +9,7 @@ interface Result extends \Iterator { function rewind(); function valid(); - function get(); + function getRow(); function getAll(); function getValue(); diff --git a/lib/Db/SQLite3/Result.php b/lib/Db/SQLite3/Result.php index 438398b3..37280290 100644 --- a/lib/Db/SQLite3/Result.php +++ b/lib/Db/SQLite3/Result.php @@ -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); } diff --git a/tests/Db/SQLite3/TestDbResultSQLite3.php b/tests/Db/SQLite3/TestDbResultSQLite3.php index 5d967fa0..f094393f 100644 --- a/tests/Db/SQLite3/TestDbResultSQLite3.php +++ b/tests/Db/SQLite3/TestDbResultSQLite3.php @@ -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()); } } \ No newline at end of file diff --git a/tests/Db/SQLite3/TestDbStatementSQLite3.php b/tests/Db/SQLite3/TestDbStatementSQLite3.php index 0600c573..694d02aa 100644 --- a/tests/Db/SQLite3/TestDbStatementSQLite3.php +++ b/tests/Db/SQLite3/TestDbStatementSQLite3.php @@ -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); }