title: Cannot access child static property from parent static method in PHP
body: <p>I am having some problem in my PHP code. I have three classes named as</p>
  
  <ol>
  <li>DatabaseObject</li>
  <li>File</li>
  <li>user_picture</li>
  </ol>
  
  <p>And their inheritance tree from parent to child class is <strong>DatabseObect->File->user_picture</strong>. Here in <strong>user_picture</strong> I have a static property $table_name that I am using to know database table name for each class and have some common database functions in <strong>DatabaseObject</strong> class. Code for a function I am using is here</p>
  
  <p><strong>Code For DatabaseObject Class</strong></p>
  
  <pre><code>public static function find_by_field($field="", $value="")
  {
      $result_array = self::find_by_sql("SELECT * FROM ".static::$table_name." WHERE {$field} = '".$value."'"); //Line 52
      if(empty($result_array))
      {
          return false;
      }
      else
      {
          $object = static::instantiate(array_shift($result_array));
          return $object;
      }
  }
  </code></pre>
  
  <p><strong>Code For File Class</strong> </p>
  
  <pre><code>public $errors=array();
  
  public $file_before_upload; // General file tyoe that has been uploaded from the form
  public $id = 0;
  public $size;
  public $file_name;
  public $file_type;
  public $user_id;
  
  protected $temp_path;
  //protected static $upload_dir="";
  
  protected $upload_errors = array(
      // http://www.php.net/manual/en/features.file-upload.errors.php
      UPLOAD_ERR_OK               =&gt; "No errors.",
      UPLOAD_ERR_INI_SIZE     =&gt; "Larger than upload_max_filesize.",
      UPLOAD_ERR_FORM_SIZE    =&gt; "Larger than form MAX_FILE_SIZE.",
      UPLOAD_ERR_PARTIAL      =&gt; "Partial upload.",
      UPLOAD_ERR_NO_FILE      =&gt; "No file.",
      UPLOAD_ERR_NO_TMP_DIR =&gt; "No temporary directory.",
      UPLOAD_ERR_CANT_WRITE =&gt; "Can't write to disk.",
      UPLOAD_ERR_EXTENSION    =&gt; "File upload stopped by extension."
  );
  public static function get_file_by_user($id = 0){
         return DatabaseObject::find_by_field("user_id",$id); //Line 164
      }
  </code></pre>
  
  <p><strong>Code for user_picture Class</strong></p>
  
  <pre><code>protected static $table_name = "user_images";
      protected static $db_fields = array('id','file_name','file_type','size','user_id');
  
      public static $upload_dir ="uploads".DS."user_img";
      protected static $file_upload_limit = 15;
  
  
      public static function get_image_by_user($id = 0)
      {
          return File::get_file_by_user($id);  //Line 45
      }
  </code></pre>
  
  <p>And From where I am calling upper function in <strong>user_picture</strong> is</p>
  
  <pre><code>$user_image = user_picture::get_image_by_user($session-&gt;user_id);
  
  $user_picture_path="";
  
  if(!$user_image)
  {
      $user_picture_path = $user_image::upload_dir.DS."default.png";
  }
  else{
      $user_picture_path = $user_image::file_path(); //Line 28
  }
  </code></pre>
  
  <p>this code gives me the following error</p>
  
  <blockquote>
    <p>Fatal error:  Uncaught Error: Access to undeclared static property: DatabaseObject::$table_name in C:\xampp\htdocs\inventory-management\includes\database\DatabaseObject.php:52
    Stack trace:</p>
    
    <p>0 C:\xampp\htdocs\inventory-management\includes\general\File.php(164): DatabaseObject::find_by_field('user_id', '29')</p>
    
    <p>1 C:\xampp\htdocs\inventory-management\includes\user\user_picture.php(45): File::get_file_by_user('29')</p>
    
    <p>2 C:\xampp\htdocs\inventory-management\public\admin\layouts\admin\header\Navigation.php(28): user_picture::get_image_by_user('29')</p>
    
    <p>3 C:\xampp\htdocs\inventory-management\public\admin\layouts\admin\header\admin_header.php(21): require_once('C:\xampp\htdocs...')</p>
    
    <p>4 C:\xampp\htdocs\inventory-management\public\admin\add_page_category.php(44): require_once('C:\xampp\htdocs...')</p>
    
    <p>5 {main}
      thrown in <b>C:\xampp\htdocs\inventory-management\includes\database\DatabaseObject.php</b> on line <b>52</b><br /></p>
  </blockquote>
  
  <p>Please if anybody can help!</p>
  
  <p>Thanks,</p>