Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Authorization {
- private $_query;
- private $array=array();
- private $_mysqli;
- public static $_singleton;
- const DB_NAME="users";
- const DB="localhost";
- const DB_PASSWORD="";
- const DB_USER="root";
- public function __construct(){
- $this->_mysqli=new mysqli(self::DB,self::DB_USER,self::DB_PASSWORD,self::DB_NAME);
- if(mysqli_connect_errno()){
- throw new Exception('There is some error while connection.');
- }
- }
- final private function __clone(){}
- public static function getInstance(){
- if(!isset(self::$_singleton)){
- self::$_singleton= new Authorization();
- }else{
- return self::$_singleton;
- }
- }
- public function query($sql){
- if($this->_query=$this->_mysqli->query($sql)){
- while($row=$this->_query->fetch_object()){
- $this->array[]=$row;
- }
- }
- return $this;
- }
- public function getArray(){
- return $this->array;
- }
- }
- print_r(Authorization::getInstance()->query("INSERT INTO authorization VALUES('jack','123123','1313231')")->getArray());
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement