summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql/mysql_statement.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-18 17:46:42 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-12-18 11:01:26 +0100
commit51f57e7b8165600be7b81a15113b150369aa7215 (patch)
tree6cd6ecf0421cfc0986bb625fd3237e8605ca5822 /ext/pdo_mysql/mysql_statement.c
parentab846231088d9e2d6a2354b52386e48037e95eb5 (diff)
downloadphp-git-51f57e7b8165600be7b81a15113b150369aa7215.tar.gz
PDO MySQL: Handle boolean parameter binding with libmysql
Previously boolean parameters were simply silently ignored...
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rw-r--r--ext/pdo_mysql/mysql_statement.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index 180a4616ef..0d0df4ca6d 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -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);