Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. class Authorization {
  2. private $_query;
  3. private $array=array();
  4. private $_mysqli;
  5. public static $_singleton;
  6. const DB_NAME="users";
  7. const DB="localhost";
  8. const DB_PASSWORD="";
  9. const DB_USER="root";
  10.  
  11.  
  12. public function __construct(){
  13. $this->_mysqli=new mysqli(self::DB,self::DB_USER,self::DB_PASSWORD,self::DB_NAME);
  14. if(mysqli_connect_errno()){
  15. throw new Exception('There is some error while connection.');
  16. }
  17. }
  18. final private function __clone(){}
  19.  
  20. public static function getInstance(){
  21. if(!isset(self::$_singleton)){
  22. self::$_singleton= new Authorization();
  23. }else{
  24. return self::$_singleton;
  25. }
  26. }
  27. public function query($sql){
  28. if($this->_query=$this->_mysqli->query($sql)){
  29. while($row=$this->_query->fetch_object()){
  30. $this->array[]=$row;
  31. }
  32. }
  33. return $this;
  34. }
  35. public function getArray(){
  36. return $this->array;
  37. }
  38.  
  39.  
  40.  
  41. }
  42. print_r(Authorization::getInstance()->query("INSERT INTO authorization VALUES('jack','123123','1313231')")->getArray());
  43.  
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement