Skip to content

Commit c4af0f8

Browse files
Fix PDO statement wrapper to work with MySQL correctly
1 parent 680ad50 commit c4af0f8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Pinoco/PDOStatementWrapper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public function execute($args=Pinoco_OptionalParam::UNSPECIFIED)
7272
{
7373
$args = func_get_args();
7474
$args = Pinoco_OptionalParam::trim($args);
75-
if (count($args) == 1) {
75+
if (count($args) == 0) {
76+
$args = null;
77+
}
78+
elseif (count($args) == 1) {
7679
$args = $args[0];
7780
if ($args instanceof Pinoco_ArrayConvertible) {
7881
$args = $args->toArray();

test/unit/PDOWrapperTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ public function testPrepareQuery()
6565
$this->assertEquals('aaa', $rs[0]->value);
6666
$this->assertEquals($b_id, $rs[1]->id);
6767
$this->assertEquals('bbb', $rs[1]->value);
68+
69+
$s = $this->db->prepare("insert into foo (value) values(:d);");
70+
$s->bindValue(':d', 'ddd');
71+
$s->execute();
72+
$d_id = $this->db->lastInsertId();
73+
$r = $this->db->prepare(
74+
"select * from foo where id=:id;"
75+
)->query($d_id)->fetchOne();
76+
$this->assertEquals($d_id, $r->get('id'));
6877
}
6978

7079
public function testStatement()

0 commit comments

Comments
 (0)