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
02bddbcf
Commit
02bddbcf
authored
Oct 22, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for transaction isolation levels, fixes #186
parent
6aad5f8e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
279 additions
and
12 deletions
+279
-12
Connection.php
lib/Doctrine/Connection.php
+16
-0
Firebird.php
lib/Doctrine/Connection/Firebird.php
+33
-2
Informix.php
lib/Doctrine/Connection/Informix.php
+26
-3
Mssql.php
lib/Doctrine/Connection/Mssql.php
+25
-1
Mysql.php
lib/Doctrine/Connection/Mysql.php
+52
-2
Oracle.php
lib/Doctrine/Connection/Oracle.php
+51
-1
Pgsql.php
lib/Doctrine/Connection/Pgsql.php
+48
-2
Sqlite.php
lib/Doctrine/Connection/Sqlite.php
+27
-0
Transaction.php
lib/Doctrine/Connection/Transaction.php
+1
-1
No files found.
lib/Doctrine/Connection.php
View file @
02bddbcf
...
...
@@ -136,6 +136,22 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
return
$this
->
dataDict
;
}
/**
* Set the transacton isolation level.
* (implemented by the connection drivers)
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
* @throws Doctrine_Connection_Mysql_Exception if using unknown isolation level
* @throws PDOException if something fails at the PDO level
* @return void
*/
public
function
setTransactionIsolation
(
$isolation
)
{
throw
new
Doctrine_Connection_Exception
(
'Transaction isolation levels not supported by this database driver.'
);
}
/**
* getRegexpOperator
* returns the regular expression operator
...
...
lib/Doctrine/Connection/Firebird.php
View file @
02bddbcf
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Connection'
);
/**
* firebird driver
* Doctrine_Connection_Firebird
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Firebird
extends
Doctrine_Connection
{
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
/**
* Adds an driver-specific LIMIT clause to the query
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
*/
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
return
preg_replace
(
'/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i'
,
"SELECT FIRST
$limit
SKIP
$offset
"
,
$query
);
}
...
...
lib/Doctrine/Connection/Informix.php
View file @
02bddbcf
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Connection'
);
/**
* informix database driver
* Doctrine_Connection_Mysql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Informix
extends
Doctrine_Connection
{
}
lib/Doctrine/Connection/Mssql.php
View file @
02bddbcf
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Connection'
);
/**
* mssql driver
* Doctrine_Connection_Mssql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Mssql
extends
Doctrine_Connection
{
/**
...
...
lib/Doctrine/Connection/Mysql.php
View file @
02bddbcf
<?php
require_once
(
"Common.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Connection_Common'
);
/**
* mysql driver
* Doctrine_Connection_Mysql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Mysql
extends
Doctrine_Connection_Common
{
...
...
@@ -23,6 +46,33 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
public
function
getRegexpOperator
()
{
return
'RLIKE'
;
}
/**
* Set the transacton isolation level.
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
* @throws Doctrine_Connection_Mysql_Exception if using unknown isolation level
* @throws PDOException if something fails at the PDO level
* @return void
*/
public
function
setTransactionIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
break
;
default
:
throw
new
Doctrine_Connection_Mysql_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
}
$query
=
"SET SESSION TRANSACTION ISOLATION LEVEL
$isolation
"
;
return
$this
->
dbh
->
query
(
$query
);
}
/**
* Returns string to concatenate two or more string parameters
*
...
...
lib/Doctrine/Connection/Oracle.php
View file @
02bddbcf
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Connection'
);
/**
* oracle driver
* Doctrine_Connection_Oracle
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Oracle
extends
Doctrine_Connection
{
/**
...
...
@@ -18,6 +42,32 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
$query
=
"SELECT
$fields
FROM (SELECT rownum as linenum,
$fields
FROM (
$query
) WHERE rownum <= (
$offset
+
$limit
)) WHERE linenum >= "
.++
$offset
;
return
$query
;
}
/**
* Set the transacton isolation level.
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
* @return mixed MDB2_OK on success, a MDB2 error on failure
*/
function
setTransactionIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$isolation
=
'READ COMMITTED'
;
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
$isolation
=
'SERIALIZABLE'
;
case
'SERIALIZABLE'
:
break
;
default
:
throw
new
Doctrine_Connection_Oracle_Exception
(
'Isolation level '
.
$isolation
.
'is not supported.'
);
}
$query
=
'ALTER SESSION ISOLATION LEVEL '
.
$isolation
;
return
$this
->
dbh
->
query
(
$query
);
}
/**
* returns the next value in the given sequence
* @param string $sequence
...
...
lib/Doctrine/Connection/Pgsql.php
View file @
02bddbcf
<?php
require_once
(
"Common.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
"Doctrine_Connection_Common"
);
/**
* pgsql driver
* Doctrine_Connection_Pgsql
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Connection_Pgsql
extends
Doctrine_Connection_Common
{
/**
...
...
@@ -14,6 +37,29 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
return
$data
[
0
];
}
/**
* Set the transacton isolation level.
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
* @return void
*/
function
setTransactionIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
break
;
throw
new
Doctrine_Connection_Pgsql_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
}
$query
=
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL '
.
$isolation
;
return
$this
->
dbh
->
query
(
$query
);
}
/**
* getRegexpOperator
*
...
...
lib/Doctrine/Connection/Sqlite.php
View file @
02bddbcf
...
...
@@ -45,6 +45,33 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
return
'datetime(\'now\')'
;
}
}
/**
* Set the transacton isolation level.
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
* @return void
*/
function
setTransactionIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$isolation
=
0
;
break
;
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
$isolation
=
1
;
break
;
default
:
throw
new
Doctrine_Connection_Sqlite_Exception
(
'Isolation level '
.
$isolation
.
'is not supported.'
);
}
$query
=
"PRAGMA read_uncommitted=
$isolation
"
;
return
$this
->
_doQuery
(
$query
,
true
);
}
/**
* return string to call a function to get a substring inside an SQL statement
*
...
...
lib/Doctrine/Connection/Transaction.php
View file @
02bddbcf
...
...
@@ -154,7 +154,7 @@ class Doctrine_Connection_Transaction implements Countable, IteratorAggregate {
}
catch
(
Exception
$e
)
{
$this
->
rollback
();
throw
new
Doctrine_Exception
(
$e
->
__toString
());
throw
new
Doctrine_
Connection_Transaction_
Exception
(
$e
->
__toString
());
}
if
(
count
(
$this
->
invalid
)
>
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