I'm trying to write a Database class. I've done this okay and can create an instance of the class and connect no problem.
I'm trying to write a query method which will allow me to pass en an array of variables for query or insert.
This is what I have, how can achieve this?
[PHP]
<?php
class Database{
public $connection;
private $result;
public function __construct(){
$this->connection = new PDO('mysql:host=localhost;dbname=as', 'root','');
}
public function query($sql) {
$result = $this->connection->prepare("$sql");
return $result;
}
public function query_par($sql, $a) {
$result = $this->connection->prepare("$sql");
$result->execute(array($a));
return $result;
}
}
$db = new Database();
?>
[/PHP]