I'm struggling to get something I think should be really simple to work. I have created a class which connects to a database using PDO and would like to initially just create a function to pass direct SQL queries to it.
class PDO_MySQL
{
private $_db;
private $connection_string;
public function __construct()
{
$this->_db = new PDO($this->connection_string, DB_USERNAME, DB_PASSWORD);
}
public function DB_Query($sql)
{
$query = $this->_db->query($sql);
return $query;
}
}
Then in my code:
$db = new PDO_MySQL();
$people = $db->DB_Query("SELECT * FROM about_us");
print_r($people);
But this is returning
PDOStatement Object ( [queryString] => SELECT * FROM about_us )
When I am looking for it to return a results set.
The connection string is set and the connection is fine i've just removed excess code for this post.
Secondary question, is this the best approach? I'm moving from MySQLi and non-Class based scripts.