I'll cut right to the chase. All I can achieve at this point with this class is a database connection. I am unable to make a query. Can you show me exactly how to get this working and/or show me how to recode it in a better way.
<?php
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(){}
}
?>