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
caf41859
Commit
caf41859
authored
Nov 16, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Doctrine_Connection
parent
d6d78241
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
77 deletions
+53
-77
Connection.php
lib/Doctrine/Connection.php
+41
-65
Sqlite.php
lib/Doctrine/Expression/Sqlite.php
+12
-12
No files found.
lib/Doctrine/Connection.php
View file @
caf41859
...
...
@@ -35,14 +35,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @var $dbh the database handler
*/
private
$dbh
;
/**
* @var Doctrine_Transaction $transaction the transaction object
*/
private
$transaction
;
/**
* @var Doctrine_UnitOfWork $unitOfWork the unit of work object
*/
private
$unitOfWork
;
/**
* @var array $tables an array containing all the initialized Doctrine_Table objects
* keys representing Doctrine_Table component names and values as Doctrine_Table objects
...
...
@@ -58,18 +50,30 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* one of the following (true, false, 'emulated')
*/
protected
$supported
=
array
();
/**
* @var Doctrine_DataDict $dataDict
*/
private
$dataDict
;
protected
$options
=
array
();
private
$modules
=
array
(
'Transaction'
=>
false
,
'Expression'
=>
false
,
'DataDict'
=>
false
,
'Export'
=>
false
,
'UnitOfWork'
=>
false
,
/**
* @var array $modules an array containing all modules
* transaction Doctrine_Transaction driver, handles savepoint and transaction isolation abstraction
*
* expression Doctrine_Expression driver, handles expression abstraction
*
* dataDict Doctrine_DataDict driver, handles datatype abstraction
*
* export Doctrine_Export driver, handles db structure modification abstraction (contains
* methods such as alterTable, createConstraint etc.)
*
* @see Doctrine_Connection::__get()
* @see Doctrine_DataDict
* @see Doctrine_Expression
* @see Doctrine_Export
* @see Doctrine_Transaction
*/
private
$modules
=
array
(
'transaction'
=>
false
,
'expression'
=>
false
,
'dataDict'
=>
false
,
'export'
=>
false
,
'unitOfWork'
=>
false
,
);
/**
* @var array $availibleDrivers an array containing all availible drivers
...
...
@@ -96,8 +100,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this
->
dbh
=
$adapter
;
$this
->
transaction
=
new
Doctrine_Connection_Transaction
(
$this
);
$this
->
unitOfWork
=
new
Doctrine_Connection_UnitOfWork
(
$this
);
$this
->
modules
[
'transaction'
]
=
new
Doctrine_Connection_Transaction
(
$this
);
$this
->
modules
[
'unitOfWork'
]
=
new
Doctrine_Connection_UnitOfWork
(
$this
);
$this
->
setParent
(
$manager
);
...
...
@@ -119,6 +123,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* __get
* lazy loads given module and returns it
*
* @see Doctrine_DataDict
* @see Doctrine_Expression
* @see Doctrine_Export
* @see Doctrine_Transaction
* @param string $name the name of the module to get
* @throws Doctrine_Connection_Exception if trying to get an unknown module
* @return Doctrine_Connection_Module connection module
...
...
@@ -129,11 +137,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if
(
$this
->
modules
[
$name
]
===
false
)
{
switch
(
$name
)
{
case
'
U
nitOfWork'
:
case
'
u
nitOfWork'
:
$this
->
modules
[
$name
]
=
new
Doctrine_Connection_UnitOfWork
(
$this
);
break
;
default
:
$class
=
'Doctrine_'
.
$name
.
'_'
.
$this
->
getName
();
$class
=
'Doctrine_'
.
ucwords
(
$name
)
.
'_'
.
$this
->
getName
();
$this
->
modules
[
$name
]
=
new
$class
(
$this
);
}
}
...
...
@@ -200,26 +208,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$str
=
str_replace
(
$this
->
identifier_quoting
[
'end'
],
$this
->
identifier_quoting
[
'escape'
]
.
$this
->
identifier_quoting
[
'end'
],
$str
);
return
$this
->
identifier_quoting
[
'start'
]
.
$str
.
$this
->
identifier_quoting
[
'end'
];
}
/**
* getUnitOfWork
*
* returns the unit of work object
*
* @return Doctrine_UnitOfWork
*/
public
function
getUnitOfWork
()
{
return
$this
->
unitOfWork
;
}
/**
* getTransaction
*
* returns the current transaction object
*
* @return Doctrine_Transaction
*/
public
function
getTransaction
()
{
return
$this
->
transaction
;
}
/**
* returns the manager that created this connection
*
...
...
@@ -261,10 +249,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return string name of the sequence with possible formatting removed
*/
public
function
fixSequenceName
(
$sqn
)
{
$seq_pattern
=
'/^'
.
preg_replace
(
'/%s/'
,
'([a-z0-9_]+)'
,
$db
->
options
[
'seqname_format'
])
.
'$/i'
;
$seq_name
=
preg_replace
(
$seq_pattern
,
'\\1'
,
$sqn
);
if
(
$seq_name
&&
!
strcasecmp
(
$sqn
,
$db
->
getSequenceName
(
$seq_name
)))
{
return
$seq_name
;
$seqPattern
=
'/^'
.
preg_replace
(
'/%s/'
,
'([a-z0-9_]+)'
,
$this
->
getAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
))
.
'$/i'
;
$seqName
=
preg_replace
(
$seqPattern
,
'\\1'
,
$sqn
);
if
(
$seqName
&&
!
strcasecmp
(
$sqn
,
$db
->
getSequenceName
(
$seqName
)))
{
return
$seqName
;
}
return
$sqn
;
}
...
...
@@ -275,27 +264,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return string name of the index with possible formatting removed
*/
public
function
fixIndexName
(
$idx
)
{
$i
dx_pattern
=
'/^'
.
preg_replace
(
'/%s/'
,
'([a-z0-9_]+)'
,
$db
->
options
[
'idxname_format'
]
)
.
'$/i'
;
$i
dx_name
=
preg_replace
(
$idx_p
attern
,
'\\1'
,
$idx
);
if
(
$i
dx_name
&&
!
strcasecmp
(
$idx
,
$db
->
getIndexName
(
$idx_n
ame
)))
{
return
$i
dx_n
ame
;
$i
ndexPattern
=
'/^'
.
preg_replace
(
'/%s/'
,
'([a-z0-9_]+)'
,
$this
->
getAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
)
)
.
'$/i'
;
$i
ndexName
=
preg_replace
(
$indexP
attern
,
'\\1'
,
$idx
);
if
(
$i
ndexName
&&
!
strcasecmp
(
$idx
,
$this
->
getIndexName
(
$indexN
ame
)))
{
return
$i
ndexN
ame
;
}
return
$idx
;
}
/**
* returns a datadict object
*
* @return Doctrine_DataDict
*/
public
function
getDataDict
()
{
if
(
isset
(
$this
->
dataDict
))
return
$this
->
dataDict
;
$class
=
'Doctrine_DataDict_'
.
$this
->
getName
();
$this
->
dataDict
=
new
$class
(
$this
->
dbh
);
return
$this
->
dataDict
;
}
/**
* Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT
* query, except that if there is already a row in the table with the same
...
...
lib/Doctrine/Expression/Sqlite.php
View file @
caf41859
...
...
@@ -72,16 +72,16 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
public
static
function
locateImpl
(
$substr
,
$str
)
{
return
strpos
(
$str
,
$substr
);
}
public
static
function
sha1
(
$str
)
{
public
static
function
sha1
Impl
(
$str
)
{
return
sha1
(
$str
);
}
public
static
function
ltrim
(
$str
)
{
public
static
function
ltrim
Impl
(
$str
)
{
return
ltrim
(
$str
);
}
public
static
function
rtrim
(
$str
)
{
public
static
function
rtrim
Impl
(
$str
)
{
return
rtrim
(
$str
);
}
public
static
function
trim
(
$str
)
{
public
static
function
trim
Impl
(
$str
)
{
return
trim
(
$str
);
}
/**
...
...
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