P. Gearman
P. Gearman

Reputation: 1166

What does Zend Db Query return on failure?

To start with, this is under Zend 1.12.

I'm writing a cron to perform certain sql based tasks (which I could run through sql directly on the database, but this is something that should be automated).

So, I've got this:

$stmt = $db->query($sql, array($binds));

If it fails due to the sql being incorrect, it throws an error. All well and fine. That's what testing is for. But if it fails to run, what does $stmt resolve to?

I want to follow it up with:

if($stmt === false)
{
    $this->logError($parameters_of_error);
}

But I'm not actually sure that $stmt will return false if it just fails to run.

So, my questions is, what will $stmt return on failure?

Upvotes: 1

Views: 285

Answers (1)

geggleto
geggleto

Reputation: 2625

From their documentation.

The query() method returns an object of type Zend_Db_Statement or PDOStatement, depending on the adapter type

Depending on configuration, PDO can throw Exceptions on errors which you can try/catch or you can inspect the resulting object that is passed back from Zend for errors.

For reference:

http://php.net/manual/en/pdostatement.errorinfo.php http://php.net/manual/en/pdostatement.errorcode.php

Upvotes: 1

Related Questions