/** * Helper function for generation and getting lock for new * random token * * @return string new token */ protected function generateNewToken() { // Generate new key for ($i = 0;; $i++) { if ($i > 10) { $this->dbConnection->rollback(); throw new Nette\InvalidStateException("Couldn't generate unused token"); } $newToken = $this->generateToken(); if ($this->dbConnection->query('SELECT * FROM %n', $this->tableName, 'WHERE [token] = %s', $newToken, 'FOR UPDATE')->fetch() === FALSE) { break; } } return $newToken; }
/** * Rollback transaction * * @param null $savepoint * * @throws \DibiException */ public function rollback($savepoint = NULL) { $this->database->rollback($savepoint); }
/** * Vrátí prováděnou transakci. * @param string $savepoint * @throws \DibiException */ public function rollback($savepoint = NULL) { $this->connection->rollback($savepoint); }