Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
608e9012
Commit
608e9012
authored
Jul 10, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted Connection::transaction to provide Connection instance by default…
Adjusted Connection::transaction to provide Connection instance by default instead of transaction instance
parent
b147e651
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
Connection.php
framework/db/Connection.php
+4
-4
ConnectionTest.php
tests/unit/framework/db/ConnectionTest.php
+2
-2
No files found.
framework/db/Connection.php
View file @
608e9012
...
...
@@ -85,8 +85,8 @@ use yii\caching\Cache;
* If needed you can pass transaction isolation level as a second parameter:
*
* ~~~
* $connection->transaction(function(
Transaction $transaction
) {
* //
$transaction->
db->...
* $connection->transaction(function(
Connection $db
) {
* //
return $
db->...
* }, Transaction::READ_UNCOMMITTED);
* ~~~
*
...
...
@@ -459,7 +459,7 @@ class Connection extends Component
/**
* Executes callback provided in a transaction.
*
* @param callable $callback a valid PHP callback that performs the job. Accepts
transa
ction instance as parameter.
* @param callable $callback a valid PHP callback that performs the job. Accepts
conne
ction instance as parameter.
* @param string|null $isolationLevel The isolation level to use for this transaction.
* See [[Transaction::begin()]] for details.
* @throws \Exception
...
...
@@ -470,7 +470,7 @@ class Connection extends Component
$transaction
=
$this
->
beginTransaction
(
$isolationLevel
);
try
{
$result
=
call_user_func
(
$callback
,
$t
ransaction
);
$result
=
call_user_func
(
$callback
,
$t
his
);
if
(
$transaction
->
isActive
)
{
$transaction
->
commit
();
}
...
...
tests/unit/framework/db/ConnectionTest.php
View file @
608e9012
...
...
@@ -155,8 +155,8 @@ class ConnectionTest extends DatabaseTestCase
{
$connection
=
$this
->
getConnection
(
true
);
$result
=
$connection
->
transaction
(
function
(
Transaction
$transaction
)
{
$
transaction
->
db
->
createCommand
()
->
insert
(
'profile'
,
[
'description'
=>
'test transaction shortcut'
])
->
execute
();
$result
=
$connection
->
transaction
(
function
(
Connection
$db
)
{
$db
->
createCommand
()
->
insert
(
'profile'
,
[
'description'
=>
'test transaction shortcut'
])
->
execute
();
return
true
;
},
Transaction
::
READ_UNCOMMITTED
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment