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
893b9b0b
Commit
893b9b0b
authored
Oct 31, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated oracle and mysql connection drivers
parent
53e9b06f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
22 deletions
+138
-22
Connection.php
lib/Doctrine/Connection.php
+47
-6
Mysql.php
lib/Doctrine/Connection/Mysql.php
+7
-0
Oracle.php
lib/Doctrine/Connection/Oracle.php
+84
-16
No files found.
lib/Doctrine/Connection.php
View file @
893b9b0b
...
...
@@ -165,38 +165,79 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return
$this
->
dataDict
;
}
/**
* returns the next value in the given sequence
*
* @param string $sequence
* @throws PDOException if something went wrong at database level
* @return integer
*/
public
function
nextId
(
$sequence
)
{
throw
new
Doctrine_Connection_Exception
(
'NextId() for sequences not supported by this driver.'
);
}
/**
* Set the charset on the current connection
*
* @param string charset
* @param resource connection handle
*
* @throws Doctrine_Connection_Exception if the feature is not supported by the driver
* @return true on success, MDB2 Error Object on failure
*/
public
function
setCharset
(
$charset
)
{
throw
new
Doctrine_Connection_Exception
(
'Altering charset not supported by this driver.'
);
}
/**
* setTransactionIsolation
*
* Set the transacton isolation level.
* (implemented by the connection drivers)
*
* example:
*
* <code>
* $conn->setTransactionIsolation('READ UNCOMMITTED');
* </code>
*
* @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_Exception if the feature is not supported by the driver
* @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 d
atabase d
river.'
);
throw
new
Doctrine_Connection_Exception
(
'Transaction isolation levels not supported by this driver.'
);
}
/**
* getTransactionIsolation
*
* @throws Doctrine_Connection_Exception if the feature is not supported by the driver
* @throws PDOException if something fails at the PDO level
* @return string returns the current session transaction isolation level
*/
public
function
getTransactionIsolation
()
{
throw
new
Doctrine_Connection_Exception
(
'Fetching transaction isolation level not supported by this d
atabase d
river.'
);
throw
new
Doctrine_Connection_Exception
(
'Fetching transaction isolation level not supported by this driver.'
);
}
/**
* query
* queries the database with Doctrine Query Language
* queries the database using Doctrine Query Language
*
* <code>
* $users = $conn->query('SELECT u.* FROM User u');
*
* $users = $conn->query('SELECT u.* FROM User u WHERE u.name LIKE ?', array('someone'));
* </code>
*
* @param string $query DQL query
* @param array $params query parameters
* @param string $query DQL query
* @param array $params query parameters
* @see Doctrine_Query
* @return Doctrine_Collection Collection of Doctrine_Record objects
*/
final
public
function
query
(
$query
,
array
$params
=
array
())
{
public
function
query
(
$query
,
array
$params
=
array
())
{
$parser
=
new
Doctrine_Query
(
$this
);
return
$parser
->
query
(
$query
,
$params
);
...
...
lib/Doctrine/Connection/Mysql.php
View file @
893b9b0b
...
...
@@ -75,11 +75,18 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
/**
* Set the transacton isolation level.
*
* example :
*
* <code>
* $conn->setTransactionIsolation('READ UNCOMMITTED');
* </code>
*
* @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
...
...
lib/Doctrine/Connection/Oracle.php
View file @
893b9b0b
...
...
@@ -30,33 +30,89 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
/**
* @var string $driverName the name of this connection driver
*/
protected
$driverName
=
'Oracle'
;
protected
$driverName
=
'Oracle'
;
public
function
__construct
()
{
$this
->
supported
=
array
(
'sequences'
=>
true
,
'indexes'
=>
true
,
'summary_functions'
=>
true
,
'order_by_text'
=>
true
,
'current_id'
=>
true
,
'affected_rows'
=>
true
,
'transactions'
=>
true
,
'savepoints'
=>
true
,
'limit_queries'
=>
true
,
'LOBs'
=>
true
,
'replace'
=>
'emulated'
,
'sub_selects'
=>
true
,
'auto_increment'
=>
false
,
// implementation is broken
'primary_key'
=>
true
,
'result_introspection'
=>
true
,
'prepared_statements'
=>
true
,
'identifier_quoting'
=>
true
,
'pattern_escaping'
=>
true
,
);
$this
->
options
[
'DBA_username'
]
=
false
;
$this
->
options
[
'DBA_password'
]
=
false
;
$this
->
options
[
'database_name_prefix'
]
=
false
;
$this
->
options
[
'emulate_database'
]
=
true
;
$this
->
options
[
'default_tablespace'
]
=
false
;
$this
->
options
[
'default_text_field_length'
]
=
2000
;
$this
->
options
[
'result_prefetching'
]
=
false
;
}
/**
* Adds an driver-specific LIMIT clause to the query
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
* @param string $query query to modify
* @param integer $limit limit the number of rows
* @param integer $offset start reading from given offset
* @return string the modified query
*/
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
/**
$e = explode("select ",strtolower($query));
$e2 = explode(" from ",$e[1]);
$fields = $e2[0];
$query
=
"SELECT
$fields
FROM (SELECT rownum as linenum,
$fields
FROM (
$query
) WHERE rownum <= (
$offset
+
$limit
)) WHERE linenum >= "
.++
$offset
;
*/
if
(
preg_match
(
'/^\s*SELECT/i'
,
$query
))
{
if
(
!
preg_match
(
'/\sFROM\s/i'
,
$query
))
{
$query
.=
" FROM dual"
;
}
if
(
$limit
>
0
)
{
// taken from http://svn.ez.no/svn/ezcomponents/packages/Database
$max
=
$offset
+
$limit
;
if
(
$offset
>
0
)
{
$min
=
$offset
+
1
;
$query
=
'SELECT * FROM (SELECT a.*, ROWNUM dctrn_rownum FROM ('
.
$query
.
') a WHERE ROWNUM <= '
.
$max
.
') WHERE dctrn_rownum >= '
.
$min
;
}
else
{
$query
=
'SELECT a.* FROM ('
.
$query
.
') a WHERE ROWNUM <= '
.
$max
;
}
}
}
return
$query
;
}
/**
* Set the transacton isolation level.
*
* example:
*
* <code>
* $conn->setTransactionIsolation('READ UNCOMMITTED');
* </code>
*
* @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
* @throws PDOException if something fails at the PDO level
* @return void
*/
function
setTransactionIsolation
(
$isolation
)
{
public
function
setTransactionIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$isolation
=
'READ COMMITTED'
;
...
...
@@ -66,7 +122,7 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
case
'SERIALIZABLE'
:
break
;
default
:
throw
new
Doctrine_Connection_Oracle_Exception
(
'Isolation level '
.
$isolation
.
'is not supported.'
);
throw
new
Doctrine_Connection_Oracle_Exception
(
'Isolation level '
.
$isolation
.
'
is not supported.'
);
}
$query
=
'ALTER SESSION ISOLATION LEVEL '
.
$isolation
;
...
...
@@ -74,16 +130,28 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
}
/**
* returns the next value in the given sequence
* @param string $sequence
*
* @param string $sequence name of the sequence
* @throws PDOException if something went wrong at database level
* @return integer
*/
public
function
getNextID
(
$sequence
)
{
$stmt
=
$this
->
query
(
"SELECT
$sequence
.nextval FROM dual"
);
public
function
nextId
(
$sequence
)
{
$stmt
=
$this
->
query
(
'SELECT '
.
$sequence
.
'.nextval FROM dual'
);
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
return
$data
[
0
];
}
/**
* Returns the current id of a sequence
*
* @param string $sequence name of the sequence
* @throws PDOException if something went wrong at database level
* @return mixed id
*/
public
function
currId
(
$sequence
)
{
$sequence
=
$this
->
quoteIdentifier
(
$this
->
getSequenceName
(
$sequence
),
true
);
$stmt
=
$this
->
query
(
'SELECT '
.
$sequence
.
'.currval FROM dual'
);
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
return
$data
[
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