Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
9b951928
Commit
9b951928
authored
Sep 20, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UnitOfWork and Transaction under the Doctrine_Connection namespace
parent
9d4c4216
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
34 deletions
+34
-34
Configurable.php
Doctrine/Configurable.php
+2
-2
Connection.php
Doctrine/Connection.php
+3
-3
Transaction.php
Doctrine/Connection/Transaction.php
+15
-15
UnitOfWork.php
Doctrine/Connection/UnitOfWork.php
+1
-1
Lib.php
Doctrine/Lib.php
+4
-4
ConnectionTestCase.php
tests/ConnectionTestCase.php
+9
-9
No files found.
Doctrine/Configurable.php
View file @
9b951928
...
@@ -87,12 +87,12 @@ abstract class Doctrine_Configurable {
...
@@ -87,12 +87,12 @@ abstract class Doctrine_Configurable {
break
;
break
;
case
Doctrine
::
ATTR_LOCKMODE
:
case
Doctrine
::
ATTR_LOCKMODE
:
if
(
$this
instanceof
Doctrine_Connection
)
{
if
(
$this
instanceof
Doctrine_Connection
)
{
if
(
$this
->
getTransaction
()
->
getState
()
!=
Doctrine_Transaction
::
STATE_OPEN
)
if
(
$this
->
getTransaction
()
->
getState
()
!=
Doctrine_
Connection_
Transaction
::
STATE_OPEN
)
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
elseif
(
$this
instanceof
Doctrine_Manager
)
{
}
elseif
(
$this
instanceof
Doctrine_Manager
)
{
foreach
(
$this
as
$connection
)
{
foreach
(
$this
as
$connection
)
{
if
(
$connection
->
getTransaction
()
->
getState
()
!=
Doctrine_Transaction
::
STATE_OPEN
)
if
(
$connection
->
getTransaction
()
->
getState
()
!=
Doctrine_
Connection_
Transaction
::
STATE_OPEN
)
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
}
}
else
{
}
else
{
...
...
Doctrine/Connection.php
View file @
9b951928
...
@@ -53,8 +53,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -53,8 +53,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public
function
__construct
(
Doctrine_Manager
$manager
,
PDO
$pdo
)
{
public
function
__construct
(
Doctrine_Manager
$manager
,
PDO
$pdo
)
{
$this
->
dbh
=
$pdo
;
$this
->
dbh
=
$pdo
;
$this
->
transaction
=
new
Doctrine_Transaction
(
$this
);
$this
->
transaction
=
new
Doctrine_
Connection_
Transaction
(
$this
);
$this
->
unitOfWork
=
new
Doctrine_UnitOfWork
(
$this
);
$this
->
unitOfWork
=
new
Doctrine_
Connection_
UnitOfWork
(
$this
);
$this
->
setParent
(
$manager
);
$this
->
setParent
(
$manager
);
...
@@ -71,7 +71,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -71,7 +71,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return Doctrine_UnitOfWork
* @return Doctrine_UnitOfWork
*/
*/
public
function
getUnitOfWork
()
{
public
function
getUnitOfWork
()
{
return
$this
->
unitOfWork
;
return
$this
->
unitOfWork
;
}
}
/**
/**
* getTransaction
* getTransaction
...
...
Doctrine/Transaction.php
→
Doctrine/
Connection/
Transaction.php
View file @
9b951928
...
@@ -20,27 +20,27 @@
...
@@ -20,27 +20,27 @@
*/
*/
/**
/**
* Doctrine_Transaction
* Doctrine_
Connection_
Transaction
*
*
* @package Doctrine ORM
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @url www.phpdoctrine.com
* @license LGPL
* @license LGPL
*/
*/
class
Doctrine_Transaction
implements
Countable
,
IteratorAggregate
{
class
Doctrine_
Connection_
Transaction
implements
Countable
,
IteratorAggregate
{
/**
/**
* Doctrine_Transaction is in open state when it is opened and there are no active transactions
* Doctrine_
Connection_
Transaction is in open state when it is opened and there are no active transactions
*/
*/
const
STATE_OPEN
=
0
;
const
STATE_OPEN
=
0
;
/**
/**
* Doctrine_Transaction is in closed state when it is closed
* Doctrine_
Connection_
Transaction is in closed state when it is closed
*/
*/
const
STATE_CLOSED
=
1
;
const
STATE_CLOSED
=
1
;
/**
/**
* Doctrine_Transaction is in active state when it has one active transaction
* Doctrine_
Connection_
Transaction is in active state when it has one active transaction
*/
*/
const
STATE_ACTIVE
=
2
;
const
STATE_ACTIVE
=
2
;
/**
/**
* Doctrine_Transaction is in busy state when it has multiple active transactions
* Doctrine_
Connection_
Transaction is in busy state when it has multiple active transactions
*/
*/
const
STATE_BUSY
=
3
;
const
STATE_BUSY
=
3
;
/**
/**
...
@@ -48,7 +48,7 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
...
@@ -48,7 +48,7 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
*/
*/
private
$connection
;
private
$connection
;
/**
/**
* @see Doctrine_Transaction::STATE_* constants
* @see Doctrine_
Connection_
Transaction::STATE_* constants
* @var boolean $state the current state of the connection
* @var boolean $state the current state of the connection
*/
*/
private
$state
=
0
;
private
$state
=
0
;
...
@@ -81,13 +81,13 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
...
@@ -81,13 +81,13 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
* @param Doctrine_Connection $conn
* @param Doctrine_Connection $conn
*/
*/
public
function
__construct
(
Doctrine_Connection
$conn
)
{
public
function
__construct
(
Doctrine_Connection
$conn
)
{
$this
->
conn
=
$conn
;
$this
->
conn
=
$conn
;
$this
->
state
=
Doctrine_Transaction
::
STATE_OPEN
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_OPEN
;
}
}
/**
/**
* returns the state of this connection
* returns the state of this connection
*
*
* @see Doctrine_Transaction::STATE_* constants
* @see Doctrine_
Connection_
Transaction::STATE_* constants
* @return integer the connection state
* @return integer the connection state
*/
*/
public
function
getState
()
{
public
function
getState
()
{
...
@@ -118,9 +118,9 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
...
@@ -118,9 +118,9 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionBegin
(
$this
->
conn
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionBegin
(
$this
->
conn
);
}
}
$this
->
state
=
Doctrine_Transaction
::
STATE_ACTIVE
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
;
}
else
{
}
else
{
$this
->
state
=
Doctrine_Transaction
::
STATE_BUSY
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_BUSY
;
}
}
$this
->
transaction_level
++
;
$this
->
transaction_level
++
;
}
}
...
@@ -174,12 +174,12 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
...
@@ -174,12 +174,12 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionCommit
(
$this
->
conn
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionCommit
(
$this
->
conn
);
$this
->
delete
=
array
();
$this
->
delete
=
array
();
$this
->
state
=
Doctrine_Transaction
::
STATE_OPEN
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_OPEN
;
$this
->
validator
=
null
;
$this
->
validator
=
null
;
}
elseif
(
$this
->
transaction_level
==
1
)
}
elseif
(
$this
->
transaction_level
==
1
)
$this
->
state
=
Doctrine_Transaction
::
STATE_ACTIVE
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
;
}
}
/**
/**
* rollback
* rollback
...
@@ -195,7 +195,7 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
...
@@ -195,7 +195,7 @@ class Doctrine_Transaction implements Countable, IteratorAggregate {
$this
->
transaction_level
=
0
;
$this
->
transaction_level
=
0
;
$this
->
conn
->
getDBH
()
->
rollback
();
$this
->
conn
->
getDBH
()
->
rollback
();
$this
->
state
=
Doctrine_Transaction
::
STATE_OPEN
;
$this
->
state
=
Doctrine_
Connection_
Transaction
::
STATE_OPEN
;
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionRollback
(
$this
->
conn
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionRollback
(
$this
->
conn
);
}
}
...
...
Doctrine/UnitOfWork.php
→
Doctrine/
Connection/
UnitOfWork.php
View file @
9b951928
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
* @url www.phpdoctrine.com
* @url www.phpdoctrine.com
* @license LGPL
* @license LGPL
*/
*/
class
Doctrine_UnitOfWork
implements
IteratorAggregate
,
Countable
{
class
Doctrine_
Connection_
UnitOfWork
implements
IteratorAggregate
,
Countable
{
/**
/**
* @var Doctrine_Connection $conn the connection object
* @var Doctrine_Connection $conn the connection object
*/
*/
...
...
Doctrine/Lib.php
View file @
9b951928
...
@@ -73,16 +73,16 @@ class Doctrine_Lib {
...
@@ -73,16 +73,16 @@ class Doctrine_Lib {
*/
*/
public
static
function
getConnectionStateAsString
(
$state
)
{
public
static
function
getConnectionStateAsString
(
$state
)
{
switch
(
$state
)
:
switch
(
$state
)
:
case
Doctrine_Transaction
::
STATE_OPEN
:
case
Doctrine_
Connection_
Transaction
::
STATE_OPEN
:
return
"open"
;
return
"open"
;
break
;
break
;
case
Doctrine_Transaction
::
STATE_CLOSED
:
case
Doctrine_
Connection_
Transaction
::
STATE_CLOSED
:
return
"closed"
;
return
"closed"
;
break
;
break
;
case
Doctrine_Transaction
::
STATE_BUSY
:
case
Doctrine_
Connection_
Transaction
::
STATE_BUSY
:
return
"busy"
;
return
"busy"
;
break
;
break
;
case
Doctrine_Transaction
::
STATE_ACTIVE
:
case
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
:
return
"active"
;
return
"active"
;
break
;
break
;
endswitch
;
endswitch
;
...
...
tests/ConnectionTestCase.php
View file @
9b951928
...
@@ -313,7 +313,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
...
@@ -313,7 +313,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$this
->
connection
->
getIterator
()
instanceof
ArrayIterator
);
$this
->
assertTrue
(
$this
->
connection
->
getIterator
()
instanceof
ArrayIterator
);
}
}
public
function
testGetState
()
{
public
function
testGetState
()
{
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
getTransaction
()
->
getState
()),
"open"
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
getTransaction
()
->
getState
()),
"open"
);
}
}
public
function
testGetTables
()
{
public
function
testGetTables
()
{
...
@@ -323,9 +323,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
...
@@ -323,9 +323,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
public
function
testTransactions
()
{
public
function
testTransactions
()
{
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
commit
();
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_OPEN
);
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
...
@@ -343,24 +343,24 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
...
@@ -343,24 +343,24 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
public
function
testRollback
()
{
public
function
testRollback
()
{
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
rollback
();
$this
->
connection
->
rollback
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
}
}
public
function
testNestedTransactions
()
{
public
function
testNestedTransactions
()
{
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_BUSY
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_BUSY
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
2
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
2
);
$this
->
connection
->
commit
();
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
connection
->
commit
();
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_
Connection_
Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
}
}
}
}
...
...
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