title: What's the Right Way to access static properties of subclasses in static methods of superclasses in PHP?
body: <p>Say I've got the following:</p>
  
  <pre><code>&lt;?php
  abstract class MyParent
  {
      public static $table_name;
  
      public static get_all(){
          return query("SELECT * FROM {$this-&gt;table_name}");
      }
  
      public static get_all2(){
          return query("SELECT * FROM ".self::table_name);
      }
  }
  
  class Child extends MyParent
  {   public static $table_name = 'child'; }
  ?&gt;
  </code></pre>
  
  <p>Assuming that <code>query</code> is correctly defined, neither of these methods does what I want: get_all() throws <code>Fatal error: Using $this when not in object context in /path/to/foo.php on line xx</code> because <code>$this</code> is an instance variable.</p>
  
  <p>and get_all2() throws <code>Fatal error: Undefined class constant 'table_name' in /path/to/foo.php on line xx</code> because <code>self</code> is statically determined.</p>
  
  <p>It seems like this kind of thing is the whole point of inheritance, so it should be possible at least easily, if not elegantly. (This is PHP after all.)</p>
  
  <p>What <em>should</em> I be doing?</p>