Bug #80874 [NEW]: odbc_fetch_array() will not fetch a row containing a UTF-8 currency code symbol
| From: | tony at tonymarston dot net | Date: | Tue, 16 Mar 2021 18:11:38 +0000 |
| Subject: | Bug #80874 [NEW]: odbc_fetch_array() will not fetch a row containing a UTF-8 currency code symbol | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-232793@lists.php.net to get a copy of this message | ||
From: tony at tonymarston dot net
Operating system: Windows 10
PHP version: 7.4.16
Package: ODBC related
Bug Type: Bug
Bug description:odbc_fetch_array() will not fetch a row containing a UTF-8 currency code symbol
Description:
------------
I have a database table in a SAP HANA database which contains currency
codes and their symbols, but when I try to read them in my PHP program
the rows containing symbols are not returned in the result set.
Test script:
---------------
CREATE TABLE currency (
currency_code nvarchar(16) NOT NULL,
currency_name nvarchar(255) NOT NULL,
currency_symbol nvarchar(4) DEFAULT NULL,
PRIMARY KEY (currency_code)
);
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('AUD', 'Australian Dollars', NULL);
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('CAD', 'Canadian Dollars', NULL);
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('EUR', 'Euros', 'â¬');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('GBP', 'UK Pounds', '£');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('JPY', 'Japanese Yen', 'Â¥');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('SGD', 'Singapore Dollar', '$');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('THB', 'Thai Baht', '฿');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('USD', 'US Dollars', '$');
INSERT INTO currency (currency_code, currency_name, currency_symbol)
VALUES ('YUAN', 'Chinese Yuan Renminbi', 'å
');
<?php
$driver = 'HDBODBC';
$server = 'hxehost:39015';
$user = '****';
$pswd = '****';
$conn = odbc_connect("Driver=$driver;ServerNode=$server",$user,$pswd) OR
die('Connection to DB via ODBC failed');
$query = "SELECT * FROM test.currency ORDER BY currency_code";
if (!$result = odbc_exec($conn, $query)) {
die("ERRORNO=".odbc_error().", ERRORMSG=".odbc_errormsg());
};
$numrows = odbc_num_rows($result);
while ($row = odbc_fetch_array($result)) {
$array[] = array_change_key_case($row, CASE_LOWER);
echo "<p>id={$row['CURRENCY_CODE']},
name={$row['CURRENCY_NAME']},
symbol={$row['CURRENCY_SYMBOL']}</p>\n";
} // while
odbc_free_result($result);
?>
Expected result:
----------------
The call to odbc_num_rows() returns '9' which is correct, but the call
to odbc_fetch_array() only returns the first 2 rows and returns FALSE
for the 3rd row.
--
Edit bug report at https://bugs.php.net/bug.php?id=80874&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80874&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80874&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80874&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80874&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80874&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80874&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80874&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80874&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80874&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80874&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80874&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80874&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80874&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80874&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80874&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80874&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80874&r=mysqlcfg