diff options
author | Scott MacVicar <scottmac@php.net> | 2008-03-07 16:58:55 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2008-03-07 16:58:55 +0000 |
commit | 4147031eb006a9041967481082a7fa271837b61d (patch) | |
tree | ca17db034af3f5ed0c50b0577377d68c128eb0d9 /ext/pdo_sqlite/sqlite_statement.c | |
parent | 8e3192aed8ef488efd92b40543268f884e1d99e8 (diff) | |
download | php-git-4147031eb006a9041967481082a7fa271837b61d.tar.gz |
Fixed bug #41135 (When binding as binary data use sqlite3_bind_blob() to stop errors with null bytes.)
Fixed bug #42443 (Bind integers and booleans as integers rather than strings.)
Diffstat (limited to 'ext/pdo_sqlite/sqlite_statement.c')
-rw-r--r-- | ext/pdo_sqlite/sqlite_statement.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index a4f2a7db35..446b8bfc9d 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -104,6 +104,21 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d pdo_sqlite_error_stmt(stmt); return 0; + case PDO_PARAM_INT: + case PDO_PARAM_BOOL: + if (Z_TYPE_P(param->parameter) == IS_NULL) { + if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { + return 1; + } + } else { + convert_to_long(param->parameter); + if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { + return 1; + } + } + pdo_sqlite_error_stmt(stmt); + return 0; + case PDO_PARAM_LOB: if (Z_TYPE_P(param->parameter) == IS_RESOURCE) { php_stream *stm; @@ -117,9 +132,25 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC); return 0; } + } else if (Z_TYPE_P(param->parameter) == IS_NULL) { + if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { + return 1; + } + pdo_sqlite_error_stmt(stmt); + return 0; + } else { + convert_to_string(param->parameter); } - /* fall through */ - + + if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, + Z_STRVAL_P(param->parameter), + Z_STRLEN_P(param->parameter), + SQLITE_STATIC)) { + return 1; + } + pdo_sqlite_error_stmt(stmt); + return 0; + case PDO_PARAM_STR: default: if (Z_TYPE_P(param->parameter) == IS_NULL) { |