I’m migrating from plain mysql_* to PDO (yeah, I know it’s 2012 on the calendar).
I’m writing a simple wrapper class to have an opportunity to do things like
$f=$db->FetchAll(“SELECT * FROM…”)
on my website.
Here’s what I’m doing:
public function Query($q, $errmessage="", $params=array()) {
try {
$stmt=$this->connect->prepare($q);
if (is_array($params) && count($params)>0) {
$stmt->execute($params);
} else {
$stmt->execute();
}
return $stmt;
} catch(PDOException $e) {
die($errmessage.": ".$e->GetMessage());
}
}
public function Fetch($q, $arraylist=0) {
if (!is_object($q)) { // Assuming it's a raw query
$stmt=$this->Query($q, "Unable to process the query for fetching");
} else $result=$q;
$f=$stmt->Fetch();
return $f;
}
And this throws a “general error 2014” exception.
Any help appreciated.
Thanks!
2014isn’t a year, it’s an error code. Try googling the error next time.or: