php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31042 oci_fetch_* set filed value to "false"
Submitted: 2004-12-09 18:59 UTC Modified: 2005-09-08 11:47 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: arhip at goldentele dot com Assigned: tony2001 (profile)
Status: Closed Package: OCI8 related
PHP Version: 5CVS-2005-04-07 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arhip at goldentele dot com
New email:
PHP Version: OS:

 

 [2004-12-09 18:59 UTC] arhip at goldentele dot com
Description:
------------
I have Oracle 8.1.7 working on linux. Some Oracle params:
NLS_RDBMS_VERSION => 8.1.7.2.0
NLS_CHARACTERSET => CL8ISO8859P5

I have table named utf8_test.
SQL> desc utf8_test;
Name Type         Nullable Default Comments 
---- ------------ -------- ------- -------- 
ID   NUMBER       Y                         
NAME VARCHAR2(10) Y                         

SQL> select * from utf8_test;

        ID NAME
---------- ----------
         1 ????
         2 ????????

The result of fetching data is depended from NLS_LANG.

When I fetched data from this table a result is depended from NLS_LANG variable.

1) When I fetch data with NLS_LANG=RUSSIAN_CIS.CL8MSWIN1251 character set, I receive 2 rows with correct data.

2) When I fetch data with NLS_LANG=RUSSIAN_CIS.UTF8 character set, I receive 2 rows,  with incorrect data. Data in NAME field in 2-nd row is incorrect (FALSE instead of '????????'). But 1-st row is correct.


I think the problem maybe in the folowing:
This field is defined in database as varchar2(10);
Length of the 1-st row NAME in UTF8 character set is 4*2=8 byte. (8<10)
Length of the 2-nd row NAME in UTF8 character set is 8*2=16 byte. (16>10).


Reproduce code:
---------------
<?
// oracle client NLS_LANG=RUSSIAN_CIS.UTF8
$conn = oci_new_connect( 'scott', 'tiger', 'DB' );
$cursor = oci_parse( $conn, 'select id, name from utf8_test' ); // tested with all oci_fetch_* functions
oci_execute( $cursor, OCI_DEFAULT );
oci_fetch_all( $cursor, $result, 0, -1, OCI_FETCHSTATEMENT_BY_ROW );
print "<pre>";
var_dump($result);
?>

Expected result:
----------------
array(2) {
  [0]=>
  array(2) {
    ["ID"]=>
    string(1) "1"
    ["NAME"]=>
    string(8) "????"
  }
  [1]=>
  array(2) {
    ["ID"]=>
    string(1) "2"
    ["NAME"]=>
    string(16) "????????"
  }
}

Actual result:
--------------
array(2) {
  [0]=>
  array(2) {
    ["ID"]=>
    string(1) "1"
    ["NAME"]=>
    string(8) "????"
  }
  [1]=>
  array(2) {
    ["ID"]=>
    string(1) "2"
    ["NAME"]=>
    bool(false)
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-10 11:21 UTC] arhip at goldentele dot com
Also tested on 5.1 snap: php5-200412100730
The result is the same.
 [2005-03-25 01:40 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-04-07 09:58 UTC] arhip at goldentele dot com
Bug does not fixed.
Tested on php5-200504070630
 [2005-09-08 11:47 UTC] tony2001@php.net
The bug has been fixed in OCI8 v.1.1, which is available in CVS HEAD and PECL (use `pear install oci8-beta` to install it).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 09:01:29 2024 UTC