本文介绍了使用PHP Oracle插入NVARCHAR列类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将所有unicode数据保存在oracle数据库中定义为nvarchar的列中:

I want to save all unicode data in a column which is defined as nvarchar like this in oracle database :

但是当我运行我的插入查询时,我进入的是nvarchar类型的列在数据库中.

but when i run my insert query i get in column which is a nvarchar typein database.

所以我的问题是->如何使用php oracle保存具有nvarchar数据类型的列的数据?

So my Question is -> How to save data for a column which has nvarchar datatype using php oracle?

这就是我想要做的事-

putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1");
putenv("LD_LIBRARY_PATH=//u01/app/oracle/product/11.2.0/db_1/lib:/lib:/usr/lib");
$conn = oci_connect('db1', 'ps1', '//xxx.xx.xx.xx:1521/orcl', 'AL32UTF8') or die('db not connected');

     $stmt=oci_parse($conn,"INSERT INTO TABLENM (VAL1, VAL2, VAL3, VAL4, VAL5 )  VALUES (:VAL1, :VAL2, :VAL3, :VAL4,  :VAL5 )");
     $VAL1 = "JK";
     $VAL2 = "10005072";
     $VAL3 = "27-JUL-17";
     $VAL4 = 1;
     $VAL5 = "आवस्यकता है ड्राइवर्स की पूर्ण विवरण के साथ संपर्क करें - यादव (8000000008)"; // VAL5 is created with datatype nvarchar in database
       oci_bind_by_name($stmt, ':VAL1', $VAL1, 1000);
       oci_bind_by_name($stmt, ':VAL2', $VAL2, 1000);
       oci_bind_by_name($stmt, ':VAL3', $VAL3, 1000);
       oci_bind_by_name($stmt, ':VAL4', $VAL4, 1000);
       oci_bind_by_name($stmt, ':VAL5', $VAL5, 1000, SQLT_LBI);


     $RES =   oci_execute($stmt, OCI_DEFAULT);
     oci_commit($conn);
     echo "<pre>";
     print_r($RES);

我从此处,但对我不起作用.

I found this SQLT_LBI from here, but its not working for me.

有没有机会做到这一点?

Is there any chances to get this Done?

请帮助!

推荐答案

PHP OCI8或PDO_OCI都不支持NVARCHAR,NCHAR或NCLOB类型. http://www.oracle .com/technetwork/topics/php/underground-php-oracle-manual-098250.html 到目前为止仍然有效:

Neither PHP OCI8 or PDO_OCI support NVARCHAR, NCHAR or NCLOB types. Page 149 of http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html is still valid as of now:

可能在某些奇怪的环境下工作(?),但这可能仅在DB字符集宽度足够大以容纳DB国家字符集的情况下.

There may be some odd environments where it works (?), but that might be only where the DB character set width is big enough to hold the DB national character set.

这篇关于使用PHP Oracle插入NVARCHAR列类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 05:24