php - Call to undefined method DB::prepare() -


i using pdo statement fetch details db, below pdo using

 <?php     define('db_host', 'localhost');     define('db_name', 's_ao');     define('db_user', 'sd');     define('db_pass', '****');     define('db_char', 'utf8');      class db     {     protected static $instance = null;      final private function __construct() {}     final private function __clone() {}      public static function instance()     {         if (self::$instance === null)         {             $opt  = array(                 pdo::attr_errmode            => pdo::errmode_exception,                 pdo::attr_default_fetch_mode => pdo::fetch_assoc,                 pdo::attr_emulate_prepares   => true,                 pdo::attr_statement_class    => array('mypdostatement'),             );             $dsn = 'mysql:host='.db_host.';dbname='.db_name.';charset='.db_char;             self::$instance = new pdo($dsn, db_user, db_pass, $opt);         }         return self::$instance;     }     public static function __callstatic($method, $args) {         return call_user_func_array(array(self::instance(), $method), $args);     }     }      class mypdostatement extends pdostatement     {     function execute($data = array())     {         parent::execute($data);         return $this;     }     } 

now when use

    $sid = $_get['pmdfe23'];     $sql = "select * checks id = '".$sid."'";      //echo $sql;     $data = db::prepare($sql)->execute()->fetchall(); 

i getting error call undefined method db::prepare(). please sort out working locally without problems , when uploaded live server getting these errors.

what's purpose of __callstatic wrapper? have factory setup return database object provides concrete methods, resulting in calls this:

$data = db::instance()->prepare($sql)->execute()->fetchall(); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -