tony2001 Wed Apr 12 19:22:12 2006 UTC
Modified files:
/php-src/ext/oci8 oci8.c oci8_statement.c
/php-src/ext/oci8/tests bind_long.phpt bind_long_raw.phpt
bind_raw.phpt test.gif
Log:
MF51: fix #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW fields)
add tests
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/oci8.c?r1=1.296&r2=1.297&diff_format=u
Index: php-src/ext/oci8/oci8.c
diff -u php-src/ext/oci8/oci8.c:1.296 php-src/ext/oci8/oci8.c:1.297
--- php-src/ext/oci8/oci8.c:1.296 Wed Apr 12 17:59:57 2006
+++ php-src/ext/oci8/oci8.c Wed Apr 12 19:22:12 2006
@@ -26,7 +26,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8.c,v 1.296 2006/04/12 17:59:57 tony2001 Exp $ */
+/* $Id: oci8.c,v 1.297 2006/04/12 19:22:12 tony2001 Exp $ */
/* TODO
*
* file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty()
with OCI_ATTR_LOBEMPTY
@@ -541,6 +541,8 @@
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);
@@ -645,7 +647,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "OCI8 Support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.296 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.297 $");
sprintf(buf, "%ld", OCI_G(num_persistent));
php_info_print_table_row(2, "Active Persistent Connections", buf);
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.18&r2=1.19&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.18
php-src/ext/oci8/oci8_statement.c:1.19
--- php-src/ext/oci8/oci8_statement.c:1.18 Sat Mar 18 22:06:45 2006
+++ php-src/ext/oci8/oci8_statement.c Wed Apr 12 19:22:12 2006
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8_statement.c,v 1.18 2006/03/18 22:06:45 tony2001 Exp $ */
+/* $Id: oci8_statement.c,v 1.19 2006/04/12 19:22:12 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
@@ -493,6 +493,9 @@
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 @@
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);
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/tests/bind_long.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/oci8/tests/bind_long.phpt
diff -u /dev/null php-src/ext/oci8/tests/bind_long.phpt:1.2
--- /dev/null Wed Apr 12 19:22:12 2006
+++ php-src/ext/oci8/tests/bind_long.phpt Wed Apr 12 19:22:12 2006
@@ -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
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/tests/bind_long_raw.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/oci8/tests/bind_long_raw.phpt
diff -u /dev/null php-src/ext/oci8/tests/bind_long_raw.phpt:1.2
--- /dev/null Wed Apr 12 19:22:12 2006
+++ php-src/ext/oci8/tests/bind_long_raw.phpt Wed Apr 12 19:22:12 2006
@@ -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
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/tests/bind_raw.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/oci8/tests/bind_raw.phpt
diff -u /dev/null php-src/ext/oci8/tests/bind_raw.phpt:1.2
--- /dev/null Wed Apr 12 19:22:12 2006
+++ php-src/ext/oci8/tests/bind_raw.phpt Wed Apr 12 19:22:12 2006
@@ -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
http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/tests/test.gif?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/oci8/tests/test.gif
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php