I'm in the process of refactoring my DAL and I will now start using mysqli and prepared statements. My first task is to use mysqli so I'm testing this now.
This is my DAL class. This is just part of the code I use:
class DAL {
private $mysqli;
(...)
// Create new mysqli object
private function conn() {
$this->mysqli = new mysqli($this->host, $this->username, $this->pwd, $this->dbname);
if(mysqli_connect_errno()) {
echo "Connection Failed: " . mysqli_connect_errno(); exit();
}
}
public function getRowByValue($table,$column, $value)
{
$this->conn();
$result = $this->mysqli->query("SELECT name FROM sl_store LIMIT 5");
$result->close();
}
When executing the mysqli query, I only get this result: Unable to query local database Query was empty. I've tested the SQL code in Toad and it returns 5 rows.
So why am I getting this error / what am I doing wrong?