André Polykanine
André Polykanine

Reputation: 3379

PDO_MYSQL: general error 2014

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!

Upvotes: 2

Views: 1245

Answers (1)

Sammitch
Sammitch

Reputation: 32242

2014 isn't a year, it's an error code. Try googling the error next time.

$pdo->query("INSERT INTO test (some) VALUES ('1111111111111111'), ('1111111111111'); -- I AM AN SQL COMMENT, REMOVING ME WILL SOLVE THIS PROBLEM");

Due to the ";" this is a multi-statement, executing two queries while the second is only a comment. The second "result" can be accessed using PDOStatement->nextRowset. [source]

or:

After spending hours trying to track down why we were getting this error on a new server, after the same code ran fine on other servers, we found the problem to be an old MySQL client library running on our web server, and a latest-version MySQL server running on the database server's box. [source]

Upvotes: 2

Related Questions