summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/sqlite_statement.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2006-12-15 05:03:02 +0000
committerWez Furlong <wez@php.net>2006-12-15 05:03:02 +0000
commitc2a7928496082de5b82977fcf328eb35803e427a (patch)
treebaba233a387b9142d101af6912fa555e69c72a5e /ext/pdo_sqlite/sqlite_statement.c
parent9db33e71bea8f5fe497af2d831cdfe5149a38a4e (diff)
downloadphp-git-c2a7928496082de5b82977fcf328eb35803e427a.tar.gz
merge php5 pdo_sqlite into head; this source compiles on both php5 and php6.
Diffstat (limited to 'ext/pdo_sqlite/sqlite_statement.c')
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index 7f77c54014..a24de6ea58 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -94,7 +94,6 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d
}
switch (PDO_PARAM_TYPE(param->param_type)) {
- case PDO_PARAM_LOB:
case PDO_PARAM_STMT:
return 0;
@@ -104,7 +103,23 @@ 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_LOB:
+ if (Z_TYPE_P(param->parameter) == IS_RESOURCE) {
+ php_stream *stm;
+ php_stream_from_zval_no_verify(stm, &param->parameter);
+ if (stm) {
+ SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);
+ Z_TYPE_P(param->parameter) = IS_STRING;
+ Z_STRLEN_P(param->parameter) = php_stream_copy_to_mem(stm,
+ &Z_STRVAL_P(param->parameter), PHP_STREAM_COPY_ALL, 0);
+ } else {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC);
+ return 0;
+ }
+ }
+ /* fall through */
+
case PDO_PARAM_STR:
default:
if (Z_TYPE_P(param->parameter) == IS_NULL) {
@@ -114,9 +129,9 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d
} else {
convert_to_string(param->parameter);
if(SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1,
- Z_STRVAL_P(param->parameter),
- Z_STRLEN_P(param->parameter),
- SQLITE_STATIC)) {
+ Z_STRVAL_P(param->parameter),
+ Z_STRLEN_P(param->parameter),
+ SQLITE_STATIC)) {
return 1;
}
}