Example #1
0
 protected function handleException(DBException $ex)
 {
     // for now, print it. Maybe later, log it.
     add_notification($ex->getMessage());
 }
Example #2
0
 /**
  * Executes SQL
  *
  * @param  string
  * @param  string
  * @param  bool
  * @return mixed   resource result or void if $expecting_results == false
  * @throws DBException
  */
 public function execute($sql, $name = null, $expecting_results = false)
 {
     if (!$this->connected) {
         $this->connect();
     }
     try {
         if ($expecting_results) {
             if (($res = mysql_query($sql, $this->connection)) === false) {
                 throw new DBException(mysql_error($this->connection), mysql_errno($this->connection), $sql);
             }
             return $res;
         } else {
             mysql_unbuffered_query($sql, $this->connection);
         }
     } catch (PHPException $e) {
         $e->stripFunctionNames('mysql_unbuffered_query', 'mysql_query');
         $e = new DBException($e, $e->getMessage());
         $e->errorInfo = $sql;
         throw $e;
     }
 }