Skip to content

Commit 51f57e7

Browse files
committed
PDO MySQL: Handle boolean parameter binding with libmysql
Previously boolean parameters were simply silently ignored...
1 parent ab84623 commit 51f57e7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ext/pdo_mysql/mysql_statement.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ static const char * const pdo_param_event_names[] =
367367
"PDO_PARAM_EVT_NORMALIZE",
368368
};
369369

370+
#ifndef PDO_USE_MYSQLND
371+
static unsigned char libmysql_false_buffer = 0;
372+
static unsigned char libmysql_true_buffer = 1;
373+
#endif
370374

371375
static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type) /* {{{ */
372376
{
@@ -503,6 +507,16 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
503507
*b->length = Z_STRLEN_P(parameter);
504508
PDO_DBG_RETURN(1);
505509

510+
case IS_FALSE:
511+
b->buffer_type = MYSQL_TYPE_TINY;
512+
b->buffer = &libmysql_false_buffer;
513+
PDO_DBG_RETURN(1);
514+
515+
case IS_TRUE:
516+
b->buffer_type = MYSQL_TYPE_TINY;
517+
b->buffer = &libmysql_true_buffer;
518+
PDO_DBG_RETURN(1);
519+
506520
case IS_LONG:
507521
b->buffer_type = MYSQL_TYPE_LONG;
508522
b->buffer = &Z_LVAL_P(parameter);

0 commit comments

Comments
 (0)