From: mail at kinesis dot me
Operating system: Ubuntu Linux 13.04 x64
PHP version: 5.4.15
Package: PDO related
Bug Type: Bug
Bug description:shuffle() and array_push are broken with PDO.
Description:
------------
$this->answer['id'] is always at the end, when it is supposed to be
shuffled.
This looks like a bug to me. array_rand() will not work either.
$this->current_set=$this->dbh->query("SELECT DISTINCT id FROM
$game_type WHERE id != '".(string)$this->answer['id']."' ORDER BY rand()
LIMIT 2;")->fetchAll(PDO::FETCH_COLUMN);
//$this->complete_set=""
//echo "Current set separated by commas is
".implode(",",$this->current_set->fetchAll(PDO::FETCH_COLUMN)) +
$this->answer['id']."<br />";
//$this->current_set=$this->current_set->fetchAll(PDO::FETCH_COLUMN);
array_push($this->current_set,$this->answer['id']);
explode(",",$this->current_set);
shuffle($this->current_set); // $this->answer['id'] is always
at the end?
print_r($this->current_set);
print_r($this->answer['id']);
var_dump($this->current_set, 3);
Test script:
---------------
$this->current_set=$this->dbh->query("SELECT DISTINCT id FROM
$game_type WHERE id != '".(string)$this->answer['id']."' ORDER BY rand()
LIMIT 2;")->fetchAll(PDO::FETCH_COLUMN);
//$this->complete_set=""
//echo "Current set separated by commas is
".implode(",",$this->current_set->fetchAll(PDO::FETCH_COLUMN)) +
$this->answer['id']."<br />";
//$this->current_set=$this->current_set->fetchAll(PDO::FETCH_COLUMN);
array_push($this->current_set,$this->answer['id']);
explode(",",$this->current_set);
shuffle($this->current_set); // $this->answer['id'] is always
at the end?
print_r($this->current_set);
print_r($this->answer['id']);
var_dump($this->current_set, 3);
Expected result:
----------------
I expect the array '$this->current_set' to have the value of $this->answer
pushed towards the end. Then I shuffle() or array_rand() the array, but
$this->answer always appears as the third element of the array no matter
what I do.
--
Edit bug report at https://bugs.php.net/bug.php?id=64864&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64864&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64864&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64864&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64864&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64864&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64864&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64864&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64864&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64864&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64864&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64864&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64864&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64864&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64864&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64864&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64864&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64864&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64864&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64864&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64864&r=mysqlcfg