Commit:    df6ca450ce1bebb7a36c0d2eecb51a28ac2f5118
Author:    Matheus Degiovani <math...@gigatron.com.br>         Fri, 22 Mar 2013 
10:39:36 -0300
Committer: Matteo Beccati <mat...@beccati.com>      Fri, 31 May 2013 14:30:57 
+0200
Parents:   65d233f06c6e274f9559880a7c187b35932b1918
Branches:  PHP-5.3 PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=df6ca450ce1bebb7a36c0d2eecb51a28ac2f5118

Log:
Fixed bug #62024 (unable to run consecutive prepared querys with null values)

Credits to ja...@kenjim.com for the patch.

Bugs:
https://bugs.php.net/62024

Changed paths:
  M  ext/pdo_firebird/firebird_statement.c
  A  ext/pdo_firebird/tests/bug_62024.phpt


Diff:
diff --git a/ext/pdo_firebird/firebird_statement.c 
b/ext/pdo_firebird/firebird_statement.c
index ffe9b3c..e172133 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -535,12 +535,12 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, 
struct pdo_bound_param_dat
                                int force_null;
                                
                                case IS_LONG:
-                                       var->sqltype = sizeof(long) == 8 ? 
SQL_INT64 : SQL_LONG;
+                                       var->sqltype = (sizeof(long) == 8 ? 
SQL_INT64 : SQL_LONG) + (var->sqltype & 1);
                                        var->sqldata = 
(void*)&Z_LVAL_P(param->parameter);
                                        var->sqllen = sizeof(long);
                                        break;
                                case IS_DOUBLE:
-                                       var->sqltype = SQL_DOUBLE;
+                                       var->sqltype = SQL_DOUBLE + 
(var->sqltype & 1);
                                        var->sqldata = 
(void*)&Z_DVAL_P(param->parameter);
                                        var->sqllen = sizeof(double);
                                        break;
@@ -560,7 +560,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, 
struct pdo_bound_param_dat
                                                        force_null = 
(Z_STRLEN_P(param->parameter) == 0);
                                        }
                                        if (!force_null) {
-                                               var->sqltype = SQL_TEXT;
+                                               var->sqltype = SQL_TEXT + 
(var->sqltype & 1);
                                                var->sqldata = 
Z_STRVAL_P(param->parameter);
                                                var->sqllen      = 
Z_STRLEN_P(param->parameter);
                                                break;
diff --git a/ext/pdo_firebird/tests/bug_62024.phpt 
b/ext/pdo_firebird/tests/bug_62024.phpt
new file mode 100644
index 0000000..3daef68
--- /dev/null
+++ b/ext/pdo_firebird/tests/bug_62024.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Bug #62024 Cannot insert second row with null using parametrized query 
(Firebird PDO)
+--SKIPIF--
+<?php extension_loaded("pdo_firebird") or die("skip"); ?>
+<?php function_exists("ibase_query") or die("skip"); ?>
+--FILE--
+<?php
+
+require("testdb.inc");
+
+$dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die;
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+$value = '2';
+@$dbh->exec('DROP TABLE test_insert');
+$dbh->exec("CREATE TABLE test_insert (ID INTEGER NOT NULL, TEXT VARCHAR(10))");
+
+$dbh->commit();
+
+//start actual test
+
+$sql = "insert into test_insert (id, text) values (?, ?)";
+$sttmt = $dbh->prepare($sql);
+
+$args_ok = [1, "test1"];
+$args_err = [2, null];
+
+$res = $sttmt->execute($args_ok);
+var_dump($res);
+
+$res = $sttmt->execute($args_err);
+var_dump($res);
+
+$dbh->commit();
+
+
+//teardown test data
+$sttmt = $dbh->prepare('DELETE FROM test_insert');
+$sttmt->execute();
+
+$dbh->commit();
+
+$dbh->exec('DROP TABLE test_insert');
+
+unset($sttmt);
+unset($dbh);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to