Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. $adduser= new Userclass();
  2. echo $adduser->addcutomer();
  3.  
  4. class db extends mysqli {
  5. private static $instance = null;
  6. private $user = "root";
  7. private $pass = "xxx";
  8. private $dbName = "xxx";
  9. private $dbHost = "localhost";
  10.  
  11. public static function getInstance() {
  12. if (!self::$instance instanceof self) {
  13. self::$instance = new self;
  14. }
  15. return self::$instance;
  16. }
  17. public function __clone() {
  18. trigger_error('Clone is not allowed.', E_USER_ERROR);
  19. }
  20. public function __wakeup() {
  21. trigger_error('Deserializing is not allowed.', E_USER_ERROR);
  22. }
  23.  
  24. private function __construct() {
  25. parent::__construct($this->dbHost, $this->user, $this->pass, $this->dbName);
  26. if (mysqli_connect_error()) {
  27. exit('Connect Error (' . mysqli_connect_errno() . ') '
  28. . mysqli_connect_error());
  29. }
  30. parent::set_charset('utf-8');
  31. }
  32.  
  33. public function dbquery($query)
  34. {
  35. if($this->query($query))
  36. {
  37. return true;
  38. }
  39.  
  40. }
  41. }
  42.  
  43. public function addcutomer(){
  44.  
  45. $query = $mysqli->prepare("INSERT INTO `user` (`firstname`,`lastname`) VALUES (?, ?)");
  46. $col1 = abc;
  47. $col2 = def;
  48. $query->bind_param('ss', $col1, $col2);
  49. $query->execute();
  50. $query->close();
  51. return true;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement