Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class database{
- public $dbHost = '';
- public $dbUser = '';
- public $dbPass = '';
- public $dbName = '';
- public $db;
- public function __construct(){}
- public function dbConnect(){
- $mysqli = new mysqli($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName);
- /* check connection */
- if (mysqli_connect_errno()){
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }else{
- echo 'connection made';
- }
- /* close connection */
- $mysqli->close();
- }
- public function query($sql){
- $query = $sql;
- self::preparedStatement($query);
- }
- public function preparedStatement(){
- if ($stmt = $mysqli->prepare($query)){
- /* execute statement */
- $stmt->execute();
- /* bind result variables */
- $stmt->bind_result($name, $code);
- /* fetch values */
- while ($stmt->fetch()) {
- printf ("%s (%s)\n", $name, $code);
- }
- /* close statement */
- $stmt->close();
- }
- }
- public function __destruct(){}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement