/**
  * Performs a query, then returns a resultset
  *
  * @param string $action[optional] The crud action performed (select, insert, update, delete, create, alter)
  *
  * @return B2DBResultset
  */
 public function performQuery($action = '')
 {
     try {
         $values = $this->getCriteria() instanceof B2DBCriteria ? $this->getCriteria()->getValues() : array();
         TBGLogging::log('executing PDO query (' . B2DB::getSQLCount() . ')', 'B2DB');
         $time = explode(' ', microtime());
         $pretime = $time[1] + $time[0];
         $res = $this->statement->execute($values);
         if (!$res) {
             $error = $this->statement->errorInfo();
             if (B2DB::isDebugMode()) {
                 $time = explode(' ', microtime());
                 $posttime = $time[1] + $time[0];
                 B2DB::sqlHit($this->printSQL(), implode(', ', $values), $posttime - $pretime);
             }
             throw new B2DBException($error[2], $this->printSQL());
         }
         if (B2DB::isDebugMode()) {
             TBGLogging::log('done', 'B2DB');
         }
         if ($this->getCriteria() instanceof B2DBCriteria && $this->getCriteria()->action == 'insert') {
             if (B2DB::getDBtype() == 'mysql') {
                 $this->insert_id = B2DB::getDBLink()->lastInsertId();
             } elseif (B2DB::getDBtype() == 'pgsql') {
                 TBGLogging::log('sequence: ' . B2DB::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq', 'b2db');
                 $this->insert_id = B2DB::getDBLink()->lastInsertId(B2DB::getTablePrefix() . $this->getCriteria()->getTable()->getB2DBName() . '_id_seq');
                 TBGLogging::log('id is: ' . $this->insert_id, 'b2db');
             }
         }
         $action = $this->getCriteria() instanceof B2DBCriteria ? $this->getCriteria()->action : '';
         $retval = new B2DBResultset($this);
         if (B2DB::isDebugMode()) {
             $time = explode(' ', microtime());
             $posttime = $time[1] + $time[0];
             B2DB::sqlHit($this->printSQL(), implode(', ', $values), $posttime - $pretime);
         }
         if (!$this->getCriteria() || $this->getCriteria()->action != 'select') {
             $this->statement->closeCursor();
         }
         return $retval;
     } catch (Exception $e) {
         throw $e;
     }
 }