本文整理匯總了PHP中Propel\Runtime\Connection\ConnectionInterface::rollBack方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConnectionInterface::rollBack方法的具體用法?PHP ConnectionInterface::rollBack怎麽用?PHP ConnectionInterface::rollBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Runtime\Connection\ConnectionInterface
的用法示例。
在下文中一共展示了ConnectionInterface::rollBack方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: applyXml
/**
* @param string $xml
*
* @return Database
*/
public function applyXml($xml)
{
$this->readDatabase();
$builder = new QuickBuilder();
$builder->setPlatform($this->database->getPlatform());
$builder->setSchema($xml);
$database = $builder->getDatabase();
$database->setSchema('migration');
$database->setPlatform($this->database->getPlatform());
$diff = DatabaseComparator::computeDiff($this->database, $database);
if (false === $diff) {
return null;
}
$sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
$this->con->beginTransaction();
$statements = SqlParser::parseString($sql);
foreach ($statements as $statement) {
try {
$stmt = $this->con->prepare($statement);
$stmt->execute();
} catch (\Exception $e) {
$this->con->rollBack();
throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
}
}
$this->con->commit();
return $database;
}
示例2: forceRollBack
/**
* Rollback the whole transaction, even if this is a nested rollback
* and reset the nested transaction count to 0.
*
* @return boolean Whether operation was successful.
*/
public function forceRollBack()
{
$return = true;
if ($this->nestedTransactionCount) {
// If we're in a transaction, always roll it back
// regardless of nesting level.
$return = $this->connection->rollBack();
// reset nested transaction count to 0 so that we don't
// try to commit (or rollback) the transaction outside this scope.
$this->nestedTransactionCount = 0;
if ($this->useDebug) {
$this->log('Rollback transaction');
}
}
return $return;
}
示例3: postActivation
public function postActivation(ConnectionInterface $con = null)
{
$con->beginTransaction();
try {
if (null === ConfigQuery::read(static::CONFIG_API_KEY)) {
$this->createConfigValue(static::CONFIG_API_KEY, ["fr_FR" => "Clé d'API pour mailjet", "en_US" => "Api key for mailjet"]);
}
if (null === ConfigQuery::read(static::CONFIG_API_SECRET)) {
$this->createConfigValue(static::CONFIG_API_SECRET, ["fr_FR" => "Secret d'API pour mailjet", "en_US" => "Api secret for mailjet"]);
}
if (null === ConfigQuery::read(static::CONFIG_NEWSLETTER_LIST)) {
$this->createConfigValue(static::CONFIG_NEWSLETTER_LIST, ["fr_FR" => "ALT de la liste de diffusion mailjet", "en_US" => "Diffusion list ALT of mailjet"]);
}
if (null === ConfigQuery::read(static::CONFIG_API_WS_ADDRESS)) {
$this->createConfigValue(static::CONFIG_API_WS_ADDRESS, ["fr_FR" => "Adresse du webservice mailjet", "en_US" => "Address of the mailjet webservice"], "https://api.mailjet.com/v3/REST");
}
$database = new Database($con);
$database->insertSql(null, [__DIR__ . "/Config/thelia.sql"]);
$con->commit();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
}
示例4: tearDown
protected function tearDown()
{
$this->con->rollBack();
}