title: PHP singelton class for PDO connection
body: <p>I have designed following class</p>
  
  <pre><code>&lt;?php 
  
      class DB { 
  
          private static $objInstance; 
  
          /* 
           * Class Constructor - Create a new database connection if one doesn't exist 
           * Set to private so no-one can create a new instance via ' = new DB();' 
           */ 
          private function __construct() {} 
  
          /* 
           * Like the constructor, we make __clone private so nobody can clone the instance 
           */ 
          private function __clone() {} 
  
          /* 
           * Returns DB instance or create initial connection 
           * @param 
           * @return $objInstance; 
           */ 
          public static function getInstance(  ) { 
  
              if(!self::$objInstance){ 
  
                  $ini_array = parse_ini_file("db.ini");
  
                  $dbInfo['server'] = $ini_array['server'];
                  $dbInfo['database'] = $ini_array['database'];
                  $dbInfo['username'] = $ini_array['username'];
                  $dbInfo['password'] = $ini_array['password'];
  
                  $dsn = 'mysql:host='.$dbInfo['server'].';dbname='.$dbInfo['database'].'';
  
                  self::$objInstance = new PDO(DB_DSN, $dbInfo['username'], $dbInfo['password']); 
                  self::$objInstance-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
              } 
  
              return self::$objInstance; 
  
          } # end method 
  
          /* 
           * Passes on any static calls to this class onto the singleton PDO instance 
           * @param $chrMethod, $arrArguments 
           * @return $mix 
           */ 
          final public static function __callStatic( $chrMethod, $arrArguments ) { 
  
              $objInstance = self::getInstance(); 
  
              return call_user_func_array(array($objInstance, $chrMethod), $arrArguments); 
  
          } # end method 
  
      }
  ?&gt;
  </code></pre>
  
  <p>My problem is when I want to perform a query I get following error:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method DB::query()</p>
  </blockquote>
  
  <pre><code>foreach(DB::query("SELECT * FROM content_type_video") as $row){ 
      print_r($row); 
  }
  </code></pre>
  
  <p>Any ideas why and how to fix this?</p>