mirror of
https://github.com/php/pecl-database-pdo_oci.git
synced 2026-03-23 23:12:16 +01:00
Fix for Input Output Bind issue Co-authored-by: Niels Dossche <7771979+ndossche@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
df964b4ab3
commit
7cea78b9b3
1
CREDITS
1
CREDITS
@@ -2,3 +2,4 @@ Oracle (OCI) driver for PDO
|
||||
Wez Furlong
|
||||
Michael Voříšek
|
||||
Ashutosh Agrawal
|
||||
Niels Dossche
|
||||
@@ -278,7 +278,7 @@ static sb4 oci_bind_output_cb(dvoid *ctx, OCIBind *bindp, ub4 iter, ub4 index, d
|
||||
|
||||
zval_ptr_dtor(parameter);
|
||||
|
||||
Z_STR_P(parameter) = zend_string_alloc(param->max_value_len, 1);
|
||||
ZVAL_NEW_STR(parameter, zend_string_alloc(param->max_value_len, false));
|
||||
P->used_for_output = 1;
|
||||
|
||||
P->actual_len = (ub4) Z_STRLEN_P(parameter);
|
||||
@@ -397,7 +397,8 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
|
||||
zval_ptr_dtor_str(parameter);
|
||||
ZVAL_UNDEF(parameter);
|
||||
} else if (Z_TYPE_P(parameter) == IS_STRING) {
|
||||
Z_STR_P(parameter) = zend_string_init(Z_STRVAL_P(parameter), P->actual_len, 1);
|
||||
ZVAL_STR(parameter, zend_string_truncate(Z_STR_P(parameter), P->actual_len, false));
|
||||
Z_STRVAL_P(parameter)[Z_STRLEN_P(parameter)] = '\0';
|
||||
}
|
||||
} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB && P->thing) {
|
||||
php_stream *stm;
|
||||
|
||||
34
tests/pdo_oci_bind_input_output.phpt
Normal file
34
tests/pdo_oci_bind_input_output.phpt
Normal file
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
PDO_OCI: Test input/output parameter binding
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_oci
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require(getenv('PDO_TEST_DIR').'/pdo_test.inc');
|
||||
PDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(getenv('PDO_TEST_DIR').'/pdo_test.inc');
|
||||
|
||||
$dbh = PDOTest::factory();
|
||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
|
||||
|
||||
$sql = <<<SQL
|
||||
begin
|
||||
:p := :p + 100;
|
||||
end;
|
||||
SQL;
|
||||
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$p = -1;
|
||||
$stmt->bindParam(':p', $p, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT, 10);
|
||||
$stmt->execute();
|
||||
var_dump($p);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(2) "99"
|
||||
Reference in New Issue
Block a user