]> granicus.if.org Git - php/commitdiff
PDO MySQL: Handle boolean parameter binding with libmysql
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Sep 2020 15:46:42 +0000 (17:46 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Dec 2020 10:01:26 +0000 (11:01 +0100)
Previously boolean parameters were simply silently ignored...

ext/pdo_mysql/mysql_statement.c

index 180a4616ef8281b5bacec8fb4f5f15cc547a24ce..0d0df4ca6d302afb141827c9abbf9c4bb92900d0 100644 (file)
@@ -367,6 +367,10 @@ static const char * const pdo_param_event_names[] =
        "PDO_PARAM_EVT_NORMALIZE",
 };
 
+#ifndef PDO_USE_MYSQLND
+static unsigned char libmysql_false_buffer = 0;
+static unsigned char libmysql_true_buffer = 1;
+#endif
 
 static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type) /* {{{ */
 {
@@ -503,6 +507,16 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
                                                *b->length = Z_STRLEN_P(parameter);
                                                PDO_DBG_RETURN(1);
 
+                                       case IS_FALSE:
+                                               b->buffer_type = MYSQL_TYPE_TINY;
+                                               b->buffer = &libmysql_false_buffer;
+                                               PDO_DBG_RETURN(1);
+
+                                       case IS_TRUE:
+                                               b->buffer_type = MYSQL_TYPE_TINY;
+                                               b->buffer = &libmysql_true_buffer;
+                                               PDO_DBG_RETURN(1);
+
                                        case IS_LONG:
                                                b->buffer_type = MYSQL_TYPE_LONG;
                                                b->buffer = &Z_LVAL_P(parameter);