Browse Source

Added test for recursive binding

Also fixed a bug uncovered by the test
microsub
J. King 7 years ago
parent
commit
b02abec250
  1. 2
      lib/Db/SQLite3/Statement.php
  2. 13
      tests/Db/SQLite3/TestDbStatementSQLite3.php

2
lib/Db/SQLite3/Statement.php

@ -85,6 +85,6 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
$a++;
}
}
return $a;
return $a - $offset;
}
}

13
tests/Db/SQLite3/TestDbStatementSQLite3.php

@ -57,6 +57,19 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
$this->assertSame($exp, $val);
}
function testBindRecursively() {
$exp = [
'one' => 1,
'two' => 2,
'three' => 3,
'four' => 4,
];
$nativeStatement = $this->c->prepare("SELECT ? as one, ? as two, ? as three, ? as four");
$s = new self::$imp($this->c, $nativeStatement, ["int", ["int", "int"], "int"]);
$val = $s->runArray([1, [2, 3], 4])->getRow();
$this->assertSame($exp, $val);
}
function testBindWithoutType() {
$nativeStatement = $this->c->prepare("SELECT ? as value");
$this->assertException("paramTypeMissing", "Db");

Loading…
Cancel
Save