I'm working on my website. To secure everything I made a new user for the database, giving it ONLY select, insert, update and delete (although not on every table).
Now, I first thought I messed something up in the permissions, but now I know I most likely didn't since even the root user doesn't return values.
This is my database class:
<?php
class database {
private $hostname = '127.0.0.1';
private $username = 'root';
private $password = '************';
private $database = 'womj';
private $connection = null;
public function __construct() {
try {
$this->connection = new PDO('mysql://' . $this->hostname . '/' . $this->database, $this->username, $this->password);
} catch (PDOException $ex) {
exit($ex->getMessage());
}
}
public function fetchResults($query) {
$stmt = $this->connection->prepare($query);
$params = array_splice(func_get_args(), 1);
$stmt->execute($params);
return $stmt->fetchAll(PDO::FETCH_OBJ);
}
}
I have a global file containing:
<?php
require 'db/database.php';
$database = new database();
In my index.php just for test (was testing db class and stuff) I have this:
<?php
require 'application/global.php';
$members = $database->fetchResults('SELECT * FROM members');
var_dump($members);
?>
I got 2 records in my database:
So I wonder why I don't get any results. In PHPMyAdmin I get the results even through the query. The server type I'm using is MariaDB. I'm hosting everything on a Debian server.