#47832 [Fbk]: Garbled associative array indices

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               47832
 Updated by:       [email protected]
 Reported By:      r dot borschel at gmx dot net
 Status:           Feedback
 Bug Type:         PDO related
 Operating System: OS X 10.5.6
 PHP Version:      5.3CVS-2009-03-29 (snap)
 Assigned To:      mysql
 New Comment:

don't have a mac at hand, if ldd doesn't work try "otool -L" ("which is
part of the developer tools")


Previous Comments:
------------------------------------------------------------------------

[2009-03-30 14:27:23] [email protected]

hm, interesting mixup, can you try doing

ldd sapi/cli/php | grep mysql

to see which libmysql is being loaded?

------------------------------------------------------------------------

[2009-03-30 12:35:27] r dot borschel at gmx dot net

$ sapi/cli/php --ri pdo_mysql

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => 5.0.38

Thats a bit strange, isnt it? My configure looks like this:

'./configure' \
...
'--with-mysql=/usr/local/mysql-5.1.32-osx10.5-x86' \
'--with-pdo-mysql=/usr/local/mysql-5.1.32-osx10.5-x86' \
...
 
That version mismatch may be the problem? Am I doing something
obviously wrong?

Thanks for your help.

------------------------------------------------------------------------

[2009-03-30 11:44:41] [email protected]

Which MySQL server and client library versions are you using? - I
tested using 5.1.31 worked for me:

$ sapi/cli/php --ri pdo_mysql

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => 5.1.31

$ sapi/cli/php bug47832.php
array(4) {
  ["c0__id"]=>
  string(1) "1"
  ["c0__status"]=>
  string(9) "developer"
  ["c0__username"]=>
  string(6) "romanb"
  ["c0__name"]=>
  string(5) "Roman"
}


------------------------------------------------------------------------

[2009-03-29 20:19:46] r dot borschel at gmx dot net

The INSERT statement should of course read:

INSERT INTO `testdb`.`cms_users` (
`id` ,
`status` ,
`username` ,
`name`
) VALUES (NULL , 'developer', 'romanb', 'Roman');

------------------------------------------------------------------------

[2009-03-29 20:17:04] r dot borschel at gmx dot net

Description:
------------
Associative array indices are getting garbled when usind pdo_mysql when
mysql & pdo_mysql were compiled against libmysql. Compiling against
mysqlnd fixes the issue.

Reproduce code:
---------------
#
# SQL
#

CREATE TABLE IF NOT EXISTS `cms_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `doctrinetests`.`cms_users` (
`id` ,
`status` ,
`username` ,
`name`
) VALUES (NULL , 'developer', 'romanb', 'Roman');

#
# PHP
#
$pdo = new PDO("mysql:host=localhost;dbname=testdb", "xxx", "xxx");

$stmt = $pdo->prepare("SELECT c0.id AS c0__id, c0.status AS c0__status,
c0.username AS c0__username, c0.name AS c0__name FROM cms_users c0");

$stmt->execute();

while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
    var_dump($data);
}

Expected result:
----------------
array(6) {
  ["c0__id"]=>  string(2) "16"
  ["c0__status"]=>  string(9) "developer"
  ["c0__username"]=>  string(6) "romanb"
  ["c0__name"]=>  string(5) "Roman"
}  

Actual result:
--------------
array(6) {
  ["c0__id"]=>  string(2) "16"
  ["status"]=>  string(9) "developer"
  ["c0"]=>  string(6) "romanb"
  ["cms_users"]=>  string(5) "Roman"
}  


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47832&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.