Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $adduser= new Userclass();
- echo $adduser->addcutomer();
- class db extends mysqli {
- private static $instance = null;
- private $user = "root";
- private $pass = "xxx";
- private $dbName = "xxx";
- private $dbHost = "localhost";
- public static function getInstance() {
- if (!self::$instance instanceof self) {
- self::$instance = new self;
- }
- return self::$instance;
- }
- public function __clone() {
- trigger_error('Clone is not allowed.', E_USER_ERROR);
- }
- public function __wakeup() {
- trigger_error('Deserializing is not allowed.', E_USER_ERROR);
- }
- private function __construct() {
- parent::__construct($this->dbHost, $this->user, $this->pass, $this->dbName);
- if (mysqli_connect_error()) {
- exit('Connect Error (' . mysqli_connect_errno() . ') '
- . mysqli_connect_error());
- }
- parent::set_charset('utf-8');
- }
- public function dbquery($query)
- {
- if($this->query($query))
- {
- return true;
- }
- }
- }
- public function addcutomer(){
- $query = $mysqli->prepare("INSERT INTO `user` (`firstname`,`lastname`) VALUES (?, ?)");
- $col1 = abc;
- $col2 = def;
- $query->bind_param('ss', $col1, $col2);
- $query->execute();
- $query->close();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement