Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class odb
- {
- static $instance = null;
- public static function getInstance()
- {
- if (null === $instance) {
- $instance = new static();
- }
- return $instance;
- }
- final private function __clone(){} // prevent cloning
- final private function __wakeup(){} // prevent unserializing
- private $PDOHost = 'localhost';
- private $PDOUser = 'username';
- private $PDOPass = 'password';
- private $PDODB = 'database';
- private $PDO = null;
- protected function __construct()
- {
- $this->PDO = new PDO('mysql:host=' . $this->PDOHost . ';' .'dbname=' . $this->PDODB, $this->PDOUser, $this->PDOPass);
- }
- }
- try{
- $stmt = odb::getInstance()->prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :user AND `password` = :pass");
- $stmt->execute(array(":user" => "tesusername", ":pass" => "testpassword"));
- print_r($stmt->fetchAll());
- }catch(Exception $e){
- die("oops");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement