Skip to content

Commit

Permalink
Fix PDO statement wrapper to work with MySQL correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tanakahisateru committed Apr 3, 2015
1 parent 680ad50 commit c4af0f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Pinoco/PDOStatementWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public function execute($args=Pinoco_OptionalParam::UNSPECIFIED)
{
$args = func_get_args();
$args = Pinoco_OptionalParam::trim($args);
if (count($args) == 1) {
if (count($args) == 0) {
$args = null;
}
elseif (count($args) == 1) {
$args = $args[0];
if ($args instanceof Pinoco_ArrayConvertible) {
$args = $args->toArray();
Expand Down
9 changes: 9 additions & 0 deletions test/unit/PDOWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public function testPrepareQuery()
$this->assertEquals('aaa', $rs[0]->value);
$this->assertEquals($b_id, $rs[1]->id);
$this->assertEquals('bbb', $rs[1]->value);

$s = $this->db->prepare("insert into foo (value) values(:d);");
$s->bindValue(':d', 'ddd');
$s->execute();
$d_id = $this->db->lastInsertId();
$r = $this->db->prepare(
"select * from foo where id=:id;"
)->query($d_id)->fetchOne();
$this->assertEquals($d_id, $r->get('id'));
}

public function testStatement()
Expand Down

0 comments on commit c4af0f8

Please sign in to comment.