summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2016-06-12 18:56:55 +0100
committerJakub Zelenka <bukka@php.net>2016-06-12 18:56:55 +0100
commitb44cf1a8540d321583a0d83ebca688ebab10d3b0 (patch)
treeb7fbafb4113ea150381a9bba7f98f45027e35b0b /ext/sqlite3/sqlite3.c
parent6ac8bc4ecb1fdf112eefdd16d2c4f971e7ac232a (diff)
parenta2f4c32eb14221de79009aadaa3da9c3349e3526 (diff)
downloadphp-git-b44cf1a8540d321583a0d83ebca688ebab10d3b0.tar.gz
Merge branch 'PHP-7.0' into openssl_error_store
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 912cc9cb2d..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(&param.parameter, parameter);
+ if (ZEND_NUM_ARGS() < 3) {
+ PHP_SQLITE3_SET_TYPE(parameter, param);
+ }
+
if (!register_bound_parameter_to_sqlite(&param, stmt_obj)) {
if (!Z_ISUNDEF(param.parameter)) {
zval_ptr_dtor(&(param.parameter));
@@ -1465,6 +1489,10 @@ PHP_METHOD(sqlite3stmt, bindValue)
ZVAL_COPY(&param.parameter, parameter);
+ if (ZEND_NUM_ARGS() < 3) {
+ PHP_SQLITE3_SET_TYPE(parameter, param);
+ }
+
if (!register_bound_parameter_to_sqlite(&param, 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)
@@ -2314,7 +2344,7 @@ zend_module_entry sqlite3_module_entry = {
#ifdef COMPILE_DL_SQLITE3
#ifdef ZTS
-ZEND_TSRMLS_CACHE_DEFINE();
+ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(sqlite3)
#endif