Skip to content

Commit

Permalink
#10 Fixed execute not working with new params
Browse files Browse the repository at this point in the history
Added test
  • Loading branch information
sbuberl committed Mar 17, 2019
1 parent 1ea26a5 commit 0f6e625
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function execute()

if($this->boundParams !== null) {
$length = strlen($this->types);
$param = current($this->boundParams);
$param = reset($this->boundParams);

$params = [];
for($i = 0; $i < $length; ++$i, $param = next($this->boundParams)) {
Expand Down
24 changes: 24 additions & 0 deletions tests/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,30 @@ public function testExecuteParams()
$this->assertTrue($passed === true);
}

public function testMultipleExecuteParams()
{
$table = CachedTable::create($this->fsql->current_schema(), 'customers', self::$columns);
$cursor = $table->getWriteCursor();
foreach (self::$entries as $entry) {
$cursor->appendRow($entry);
}
$table->commit();

$statement = new Statement($this->fsql);
$statement->prepare("SELECT firstName, lastName, city FROM customers WHERE personId = ? OR lastName = ? OR zip = ?");
$id = 5;
$lastName = 'king';
$zip = 99999;
$statement->bind_param('isd', $id, $lastName, $zip);
$passed = $statement->execute();
$this->assertTrue($passed === true);
$id = 1;
$lastName = 'adams';
$zip = null;
$passed = $statement->execute();
$this->assertTrue($passed === true);
}

public function testBindResultNoPrepare()
{
$statement = new Statement($this->fsql);
Expand Down

0 comments on commit 0f6e625

Please sign in to comment.