]> granicus.if.org Git - php/commitdiff
MF51: fix #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW fields)
authorAntony Dovgal <tony2001@php.net>
Wed, 12 Apr 2006 19:22:12 +0000 (19:22 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 12 Apr 2006 19:22:12 +0000 (19:22 +0000)
add tests

ext/oci8/oci8.c
ext/oci8/oci8_statement.c
ext/oci8/tests/bind_long.phpt [new file with mode: 0644]
ext/oci8/tests/bind_long_raw.phpt [new file with mode: 0644]
ext/oci8/tests/bind_raw.phpt [new file with mode: 0644]
ext/oci8/tests/test.gif [new file with mode: 0644]

index 87e5f3a775159bc90b173b49f389c9fa982852b0..1c73008ed457fed10a71fdce3796e1e25155ed7e 100644 (file)
@@ -541,6 +541,8 @@ PHP_MINIT_FUNCTION(oci)
        REGISTER_LONG_CONSTANT("SQLT_FLT",SQLT_FLT, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLT_UIN",SQLT_UIN, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLT_LNG",SQLT_LNG, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("SQLT_LBI",SQLT_LBI, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("SQLT_BIN",SQLT_BIN, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLT_ODT",SQLT_ODT, CONST_CS | CONST_PERSISTENT);
 #if defined(HAVE_OCI_INSTANT_CLIENT) || (defined(OCI_MAJOR_VERSION) && OCI_MAJOR_VERSION > 10)
        REGISTER_LONG_CONSTANT("SQLT_BDOUBLE",SQLT_BDOUBLE, CONST_CS | CONST_PERSISTENT);
index f930fdaa7706fea12d5ea03ca70259863db071c2..16a2b7e1822b68713ee0a6f6d2c9be488d93dcd3 100644 (file)
@@ -493,6 +493,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
                                case SQLT_BIN:
                                default:
                                        define_type = SQLT_CHR;
+                                       if (outcol->data_type == SQLT_BIN) {
+                                               define_type = SQLT_BIN;
+                                       }
                                        if ((outcol->data_type == SQLT_DAT) || (outcol->data_type == SQLT_NUM)
 #ifdef SQLT_TIMESTAMP
                                                || (outcol->data_type == SQLT_TIMESTAMP)
@@ -813,6 +816,9 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
                        mode = OCI_DEFAULT;
                        break;
                        
+               case SQLT_LBI:
+               case SQLT_BIN:
+               case SQLT_LNG:
                case SQLT_CHR:
                        /* this is the default case when type was not specified */
                        convert_to_string(var);
diff --git a/ext/oci8/tests/bind_long.phpt b/ext/oci8/tests/bind_long.phpt
new file mode 100644 (file)
index 0000000..58590f1
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+bind LONG field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestlng( id number(10), fileimage long)");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestlng (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LNG);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestlng");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestlng");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "d04e7036e2f4221abc88fd14e960a45b"
+int(2523)
+Done
diff --git a/ext/oci8/tests/bind_long_raw.phpt b/ext/oci8/tests/bind_long_raw.phpt
new file mode 100644 (file)
index 0000000..2a9962e
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+bind LONG RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestlngraw( id number(10), fileimage long raw)");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestlngraw (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_LBI);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestlngraw");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestlngraw");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "614fcbba1effb7caa27ef0ef25c27fcf"
+int(2523)
+Done
diff --git a/ext/oci8/tests/bind_raw.phpt b/ext/oci8/tests/bind_raw.phpt
new file mode 100644 (file)
index 0000000..c9087e5
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+bind RAW field
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+
+$stmt = oci_parse($c, "create table phptestrawtable( id number(10), fileimage raw(1000))");
+oci_execute($stmt);
+
+$stmt = oci_parse ($c, "insert into phptestrawtable (id, fileimage) values (:id, :fileimage)");
+$i=1;
+$fileimage = file_get_contents( dirname(__FILE__)."/test.gif");
+$fileimage = substr($fileimage, 0, 300);
+
+oci_bind_by_name( $stmt, ":id", $i, -1);
+oci_bind_by_name( $stmt, ":fileimage", $fileimage, -1, SQLT_BIN);
+oci_execute($stmt, OCI_DEFAULT);
+oci_commit($c);
+
+$stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable");
+oci_execute($stmt);
+
+$row = oci_fetch_row($stmt);
+var_dump(md5($row[0]));
+var_dump(strlen($row[0]));
+
+$stmt = oci_parse($c, "drop table phptestrawtable");
+oci_execute($stmt);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(32) "88b274d7a257ac6f70435b83abd4e26e"
+int(300)
+Done
diff --git a/ext/oci8/tests/test.gif b/ext/oci8/tests/test.gif
new file mode 100644 (file)
index 0000000..f352c73
Binary files /dev/null and b/ext/oci8/tests/test.gif differ