php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25973 object attributes & array mix up
Submitted: 2003-10-24 04:23 UTC Modified: 2003-11-05 00:34 UTC
From: mike dot blamires at kingston-callcentres dot co dot uk Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.0.0b1 (beta1) OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 + 22 = ?
Subscribe to this entry?

 
 [2003-10-24 04:23 UTC] mike dot blamires at kingston-callcentres dot co dot uk
Description:
------------
When I have set a list of the objects attributes from an array, after successfully setting all the attributes to there values (and echoing them as they should be, set to the correct values) all the attributes take on that last value set.

In the example below the value last set to an attribute was element 2 of the array, the integer 4, now all attributes are set are set to 4. this is the same if the last  attribute set was element 8, all attributes would refer to "aJobTitle"

I believe this to be similar to bug 25957, although I was not totally sure of the actual bug highlighted there so i reported as a seperate issue.

Reproduce code:
---------------
abstract class Person extends OwlObj {
        private $name;
        private $group;
        public function initialize() {
                $users = $this->dbQuery("SELECT fullname, group, dateCreated, ammendedBy, dateAmmended, allowedReport, priorityReport, description, onlinePass FROM tblUser WHERE userID=".$_SESSION['userName']."");     
                //$users is a single dimension array filled with the SQL results 
                print_r($users);
                echo"<br>";
                $this->$name = $users[1];
                echo "~ name: ".$this->$name."<br>";
                $this->$group = $users[2];
                echo "~ group: ".$this->$group."<br>";
                echo "[".$this->$name." ".$this->$group."]<br>";
                echo "name: ".$this->$name."<br>";
        }
}

Expected result:
----------------
Array ( [1] => aName [2] => 4 [3] => 2001-10-13 00:00:00 [4] => System [5] => 2003-07-22 00:00:00 [6] => 1 [7] => 1 [8] => aJobTitle [9] => password ) 
~ name: aName
~ group: 4
[aName 4]
name: aName

  

Actual result:
--------------
Array ( [1] => aName [2] => 4 [3] => 2001-10-13 00:00:00 [4] => System [5] => 2003-07-22 00:00:00 [6] => 1 [7] => 1 [8] => aJobTitle [9] => aPassword ) 
~ name: 4
~ group: 4
[4 4]
name: 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-30 20:57 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


 [2003-11-05 00:34 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC