|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-20 15:22 UTC] mauroi at digbang dot com
Description: ------------ I'm trying to use a AL32UTF8 database with PDO, but it seems that the charset is not correctly set (I get funny characters in the output). I've tried the method described in (http://www.oracle.com/technology/pub/articles/php_experts/otn_pdo_oracle5.html) with no success. I'm using Oracle instant client for Windows. Reproduce code: --------------- sql: create table foo (field varchar(10)); php: $a = new PDO('oci:dbname=server;charset=UTF-8', 'user', 'password'); $a->beginTransaction(); $b = $a->prepare('insert into foo (field) values (?)'); $b->bindValue(1, '?????'); $b->execute(); $c = $a->prepare('select * from foo'); $c->execute(); var_dump($c->fetchAll()); $a->rollBack(); Expected result: ---------------- the result with the row with ????? correctly displayed PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 17:00:01 2025 UTC |
Here's some more reproduce code: <?php $dbh = new PDO("oci:dbname=asylum;charset=UTF-8", "dev", "dev"); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Create table $dbh->exec('create table my_test_table(my_field varchar2(100))'); // Insert data $dbh->exec('insert into my_test_table(my_field) values (\'foo\')'); $dbh->exec('insert into my_test_table(my_field) values (\'日本語 \')'); // Get data foreach ($dbh->query('select my_field from my_test_table') as $row) { var_dump($row); } $dbh->exec('drop table my_test_table'); ?> ACTUAL OUTPUT: array(2) { ["MY_FIELD"]=> string(3) "foo" [0]=> string(3) "foo" } array(2) { ["MY_FIELD"]=> string(4) "??? " [0]=> string(4) "??? " } EXPECTED OUTPUT: array(2) { ["MY_FIELD"]=> string(3) "foo" [0]=> string(3) "foo" } array(2) { ["MY_FIELD"]=> string(4) "日本語 " [0]=> string(4) "日本語 " }