title: How to override a static property of a parent object and let the parent object access the new value in PHP?
body: <p>This is what I have: All objects that can be persisted on the database extend the DatabaseObject abstract class, which has all the logic code to actually watch for attribute changes and run the databas queries.</p>
  
  <p>I'm using two static variables to define object-specific details. I define them generically in the base class, and then supposedly I overwrite them in the actual database objects.</p>
  
  <p>The problem is: When the code in the parent class is actually executed, it uses the old parent value instead of the current object value.</p>
  
  <p>Here's the code for the base class:</p>
  
  <pre><code>abstract class DatabaseObject {
  
      public $id;
  
      private static $databaseTable = NULL;
      private static $databaseFields = array();
  
      private $data = array();
      private $changedFields = array();
  
      public function IDatabaseObject($id) {
      $this-&gt;id = $id;
      $this-&gt;data = Database::GetSingle(self::$databaseTable, $id);
  
      Utils::copyToObject($this, $this-&gt;data, self::$databaseFields);
      }
  
      public static function Load($id) {
      return new self($userID);
      }
  
      public static function Create($data) {
  
      $id = Database::Insert(self::$databaseTable, $data);
  
      return new self($id);
      }
  
      public function Save() {
      $data = Utils::copyFromObject($this, $this-&gt;changedFields);
  
      Database::Update(self::$databaseTable, $data, $this-&gt;id);
  
      }
  
      public function __constructor() {
      // We do this to allow __get and __set to be called on public vars
      foreach(self::$databaseFields as $field) {
          unset($this-&gt;$field);
      }
      }
  
      public function __get($variableName) {
      return $this-&gt;$variableName;
      }
  
      public function __set($variableName, $variableValue) {
      // We only want to update what has been changed
      if(!in_array($variableName, $this-&gt;changedFields) &amp;&amp; in_array($variableName, self::$databaseFields)) {
          array_push($this-&gt;changedFields, $variableName);
      }
  
      $this-&gt;$variableName = $variableValue;
      }
  }
  </code></pre>
  
  <p>And here's the code for one of the objects extending the base class above:</p>
  
  <pre><code>class Client extends DatabaseObject {
  
      public static $databaseTable = "clients";
      public static $databaseFields = array("name","contactName","primaryUserID","email","is_active","rg","cpf","cnpj","ie","addrType","addrName","addrNumber","addrComplement","addrPostalCode","addrNeighborhood","addrCity","addrState","addrCountry","phoneLandline","phoneFax","phoneMobile");
  
      public $name;
      public $contactName;
  
      public $primaryUserID;
      public $email;
  
      public $is_active;
  
      public $rg;
      public $cpf;
      public $cnpj;
      public $ie;
  
      public $addrType;
      public $addrName;
      public $addrNumber;
      public $addrComplement;
      public $addrPostalCode;
      public $addrNeighborhood;
      public $addrCity;
      public $addrState;
      public $addrCountry;
  
      public $phoneLandline;
      public $phoneFax;
      public $phoneMobile;
  
      public static function Load($id) {
   return new Client($id);
      }
  
  }
  </code></pre>
  
  <p>What am I doing wrong here? Is there another way I can achieve the same result?</p>
  
  <p>A brief addendum: I declare the attributes in the class body mainly to let it be seen by the NetBeans' auto-complete feature.</p>