public function rollback()
 {
     if ($this->state == self::DB_TRANSACTION_STARTED) {
         if (B2DB::getDBLink()->rollback()) {
             $this->state = self::DB_TRANSACTION_ROLLEDBACK;
             B2DB::setTransaction(false);
         } else {
             throw new B2DBException('Error rolling back transaction: ' . B2DB::getDBLink()->error);
         }
     } else {
         throw new B2DBException('There is no active transaction');
     }
 }
 /**
  * Prepare the statement
  */
 protected function _prepare()
 {
     try {
         if (!B2DB::getDBLink() instanceof PDO) {
             throw new B2DBException('Connection not up, can\'t prepare the statement');
         }
         if ($this->crit instanceof B2DBCriteria) {
             $this->statement = B2DB::getDBLink()->prepare($this->crit->getSQL());
         } else {
             $this->statement = B2DB::getDBLink()->prepare($this->custom_sql);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }