diff options
author | Anatol Belski <ab@php.net> | 2016-04-12 19:12:45 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-04-12 19:12:45 +0200 |
commit | e49580c96e189b3574a3cbf65d96a7173feb07f0 (patch) | |
tree | e1c607b23e1f7d7924e4b4dc2121cf9d4d57014c /ext/sqlite3/sqlite3.c | |
parent | 4e585eb42941cead2a1a3f9824c84d03af621391 (diff) | |
download | php-git-e49580c96e189b3574a3cbf65d96a7173feb07f0.tar.gz |
Fixed bug #68849 bindValue is not using the right data type
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r-- | ext/sqlite3/sqlite3.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index e497d7b183..741a6ad0c2 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1406,6 +1406,26 @@ static int register_bound_parameter_to_sqlite(struct php_sqlite3_bound_param *pa } /* }}} */ +/* {{{ Best try to map between PHP and SQLite. Default is still text. */ +#define PHP_SQLITE3_SET_TYPE(z, p) \ + switch (Z_TYPE_P(z)) { \ + default: \ + (p).type = SQLITE_TEXT; \ + break; \ + case IS_LONG: \ + case IS_TRUE: \ + case IS_FALSE: \ + (p).type = SQLITE_INTEGER; \ + break; \ + case IS_DOUBLE: \ + (p).type = SQLITE_FLOAT; \ + break; \ + case IS_NULL: \ + (p).type = SQLITE_NULL; \ + break; \ + } +/* }}} */ + /* {{{ proto bool SQLite3Stmt::bindParam(int parameter_number, mixed parameter [, int type]) Bind Parameter to a stmt variable. */ PHP_METHOD(sqlite3stmt, bindParam) @@ -1430,6 +1450,10 @@ PHP_METHOD(sqlite3stmt, bindParam) ZVAL_COPY(¶m.parameter, parameter); + if (ZEND_NUM_ARGS() < 3) { + PHP_SQLITE3_SET_TYPE(parameter, param); + } + if (!register_bound_parameter_to_sqlite(¶m, stmt_obj)) { if (!Z_ISUNDEF(param.parameter)) { zval_ptr_dtor(&(param.parameter)); @@ -1465,6 +1489,10 @@ PHP_METHOD(sqlite3stmt, bindValue) ZVAL_COPY(¶m.parameter, parameter); + if (ZEND_NUM_ARGS() < 3) { + PHP_SQLITE3_SET_TYPE(parameter, param); + } + if (!register_bound_parameter_to_sqlite(¶m, stmt_obj)) { if (!Z_ISUNDEF(param.parameter)) { zval_ptr_dtor(&(param.parameter)); @@ -1476,6 +1504,8 @@ PHP_METHOD(sqlite3stmt, bindValue) } /* }}} */ +#undef PHP_SQLITE3_SET_TYPE + /* {{{ proto SQLite3Result SQLite3Stmt::execute() Executes a prepared statement and returns a result set object. */ PHP_METHOD(sqlite3stmt, execute) |