Browse Source

added missing namespace on Exception in transaction docs

fixes #9429
9899-cache-bug
Carsten Brandt 9 years ago
parent
commit
620ec4d132
  1. 8
      docs/guide/db-dao.md
  2. 7
      framework/db/Transaction.php

8
docs/guide/db-dao.md

@ -365,7 +365,7 @@ the changes made by the queries prior to that failed query in the transaction.
### Specifying Isolation Levels <span id="specifying-isolation-levels"></span>
Yii also supports setting [isolation levels] for your transactions. By default, when starting a new transaction,
it will use the isolation level set by your database system. You can override the default isolation level as follows,
it will use the default isolation level set by your database system. You can override the default isolation level as follows,
```php
$isolationLevel = \yii\db\Transaction::REPEATABLE_READ;
@ -429,13 +429,15 @@ try {
try {
$db->createCommand($sql2)->execute();
$innerTransaction->commit();
} catch (Exception $e) {
} catch (\Exception $e) {
$innerTransaction->rollBack();
throw $e;
}
$outerTransaction->commit();
} catch (Exception $e) {
} catch (\Exception $e) {
$outerTransaction->rollBack();
throw $e;
}
```

7
framework/db/Transaction.php

@ -18,17 +18,18 @@ use yii\base\InvalidConfigException;
* The following code is a typical example of using transactions (note that some
* DBMS may not support transactions):
*
* ~~~
* ```php
* $transaction = $connection->beginTransaction();
* try {
* $connection->createCommand($sql1)->execute();
* $connection->createCommand($sql2)->execute();
* //.... other SQL executions
* $transaction->commit();
* } catch (Exception $e) {
* } catch (\Exception $e) {
* $transaction->rollBack();
* throw $e;
* }
* ~~~
* ```
*
* @property boolean $isActive Whether this transaction is active. Only an active transaction can [[commit()]]
* or [[rollBack()]]. This property is read-only.

Loading…
Cancel
Save