From: Felipe Pena Date: Tue, 12 Aug 2008 13:32:30 +0000 (+0000) Subject: - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~752 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98c445c97154954eed1d620d94f54b6876df2a74;p=php - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound) --- diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 30bca6e2fa..2e1578b2b8 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1096,6 +1096,7 @@ PHP_METHOD(sqlite3stmt, execute) /* If the ZVAL is null then it should be bound as that */ if (Z_TYPE_P(param->parameter) == IS_NULL) { sqlite3_bind_null(stmt_obj->stmt, param->param_number); + zend_hash_move_forward(stmt_obj->bound_params); continue; } diff --git a/ext/sqlite3/tests/bug45798.phpt b/ext/sqlite3/tests/bug45798.phpt new file mode 100644 index 0000000000..1beacc4910 --- /dev/null +++ b/ext/sqlite3/tests/bug45798.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #45798 (sqlite3 doesn't notice if variable was bound) +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test (time INTEGER, id STRING)'); + +$db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'a')"); +$db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'b')"); + +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); + +$stmt->bindParam(1, $foo, SQLITE3_TEXT); +$results = $stmt->execute(); + +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} + +$results->finalize(); + +$db->close(); + +print "done"; + +?> +--EXPECT-- +done