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
e49a686a
Commit
e49a686a
authored
Sep 22, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some event hooks added
parent
6ef092c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
59 deletions
+57
-59
DB.php
draft/DB.php
+57
-59
No files found.
draft/DB.php
View file @
e49a686a
...
@@ -63,6 +63,12 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -63,6 +63,12 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
/**
/**
* @var PDO $dbh the database handler
* @var PDO $dbh the database handler
*/
*/
protected
$dbh
;
/**
* @var Doctrine_DB_EventListener_Interface $listener listener for listening events
*/
protected
$listener
;
/**
/**
* constructor
* constructor
...
@@ -75,6 +81,7 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -75,6 +81,7 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
$this
->
dsn
=
$dsn
;
$this
->
dsn
=
$dsn
;
$this
->
username
=
$username
;
$this
->
username
=
$username
;
$this
->
password
=
$password
;
$this
->
password
=
$password
;
$this
->
listener
=
new
Doctrine_DB_EventListener
();
}
}
/**
/**
* getDSN
* getDSN
...
@@ -117,28 +124,28 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -117,28 +124,28 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
/**
/**
* getConnection
* getConnection
*
*
* @param string $dsn
PEAR::DB
like DSN
* @param string $dsn
PEAR::DB like DSN or PDO
like DSN
* format
:
schema://user:password@address/dbname
* format
for PEAR::DB like DSN:
schema://user:password@address/dbname
*
*
* @return
* @return
*/
*/
public
static
function
getConnection
(
$dsn
=
null
,
$username
=
null
,
$password
=
null
)
{
public
static
function
getConnection
(
$dsn
=
null
,
$username
=
null
,
$password
=
null
)
{
$md5
=
md5
(
$dsn
);
$md5
=
md5
(
$dsn
);
if
(
!
isset
(
self
::
$instances
[
$md5
]))
{
if
(
isset
(
$username
))
{
if
(
isset
(
$username
))
{
self
::
$instances
[
$md5
]
=
new
self
(
$dsn
,
$username
,
$password
);
self
::
$instances
[
$md5
]
=
new
self
(
$dsn
,
$username
,
$password
);
}
if
(
!
isset
(
self
::
$instances
[
$md5
]))
{
if
(
!
isset
(
$dsn
))
{
$a
=
self
::
parseDSN
(
self
::
DSN
);
}
else
{
}
else
{
if
(
!
isset
(
$dsn
))
$a
=
self
::
parseDSN
(
self
::
DSN
);
else
$a
=
self
::
parseDSN
(
$dsn
);
$a
=
self
::
parseDSN
(
$dsn
);
}
extract
(
$a
);
extract
(
$a
);
self
::
$instances
[
$md5
]
=
new
self
(
$dsn
,
$user
,
$pass
);
self
::
$instances
[
$md5
]
=
new
self
(
$dsn
,
$user
,
$pass
);
}
}
}
return
self
::
$instances
[
$md5
];
return
self
::
$instances
[
$md5
];
}
}
/**
/**
...
@@ -158,8 +165,6 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -158,8 +165,6 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return integer
* @return integer
*/
*/
public
function
errorCode
()
{
public
function
errorCode
()
{
$this
->
connect
();
return
$this
->
dbh
->
errorCode
();
return
$this
->
dbh
->
errorCode
();
}
}
/**
/**
...
@@ -169,19 +174,21 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -169,19 +174,21 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return array
* @return array
*/
*/
public
function
errorInfo
()
{
public
function
errorInfo
()
{
$this
->
connect
();
return
$this
->
dbh
->
errorInfo
();
return
$this
->
dbh
->
errorInfo
();
}
}
/**
/**
*
*
prepare
*
*
* @param string $statement
* @param string $statement
*/
*/
public
function
prepare
(
$statement
)
{
public
function
prepare
(
$statement
)
{
$this
->
connect
();
$this
->
listener
->
onPrePrepare
(
$this
,
$statement
);
$this
->
queries
[]
=
$query
;
return
$this
->
dbh
->
prepare
(
$statement
);
$stmt
=
$this
->
dbh
->
prepare
(
$statement
);
$this
->
listener
->
onPrepare
(
$this
,
$statement
);
return
$stmt
;
}
}
/**
/**
* query
* query
...
@@ -190,14 +197,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -190,14 +197,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return Doctrine_DB_Statement|boolean
* @return Doctrine_DB_Statement|boolean
*/
*/
public
function
query
(
$statement
,
$fetchMode
=
null
,
$arg
=
null
,
$arg2
=
null
)
{
public
function
query
(
$statement
,
$fetchMode
=
null
,
$arg
=
null
,
$arg2
=
null
)
{
$
this
->
connect
();
$
args
=
func_get_args
();
$this
->
queries
[]
=
$query
;
$this
->
listener
->
onPreQuery
(
$this
,
$args
);
$time
=
microtime
();
$stmt
=
$this
->
dbh
->
query
(
$
query
,
$fetchMode
,
$arg
,
$arg2
);
$stmt
=
$this
->
dbh
->
query
(
$
statement
,
$fetchMode
,
$arg
,
$arg2
);
$this
->
exectimes
[]
=
(
microtime
()
-
$time
);
$this
->
listener
->
onQuery
(
$this
,
$args
);
return
$stmt
;
return
$stmt
;
}
}
...
@@ -221,9 +227,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -221,9 +227,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return integer
* @return integer
*/
*/
public
function
exec
(
$statement
)
{
public
function
exec
(
$statement
)
{
$this
->
connect
();
$this
->
listener
->
onPreExec
(
$this
,
$statement
);
$rows
=
$this
->
dbh
->
exec
(
$statement
);
return
$this
->
dbh
->
exec
(
$statement
);
$this
->
listener
->
onExec
(
$this
,
$statement
);
return
$rows
;
}
}
/**
/**
* lastInsertId
* lastInsertId
...
@@ -241,9 +251,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -241,9 +251,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return boolean
* @return boolean
*/
*/
public
function
beginTransaction
()
{
public
function
beginTransaction
()
{
$this
->
connect
();
$this
->
listener
->
onPreBeginTransaction
(
$this
);
$return
=
$this
->
dbh
->
beginTransaction
();
return
$this
->
dbh
->
beginTransaction
();
$this
->
listener
->
onBeginTransaction
(
$this
);
return
$return
;
}
}
/**
/**
* commits a transaction
* commits a transaction
...
@@ -251,9 +265,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -251,9 +265,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
* @return boolean
* @return boolean
*/
*/
public
function
commit
()
{
public
function
commit
()
{
$this
->
connect
();
$this
->
listener
->
onPreCommit
(
$this
);
$return
=
$this
->
dbh
->
commit
();
return
$this
->
dbh
->
commit
();
$this
->
listener
->
onCommit
(
$this
);
return
$return
;
}
}
/**
/**
* rollBack
* rollBack
...
@@ -296,26 +314,6 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
...
@@ -296,26 +314,6 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
$this
->
dbh
->
setAttribute
(
$attribute
,
$value
);
$this
->
dbh
->
setAttribute
(
$attribute
,
$value
);
}
}
/**
* @param string $time exectime of the last executed query
* @return void
*/
public
function
addExecTime
(
$time
)
{
$this
->
exectimes
[]
=
$time
;
}
public
function
getExecTimes
()
{
return
$this
->
exectimes
;
}
/**
* getQueries
* returns an array of executed queries
*
* @return array
*/
public
function
getQueries
()
{
return
$this
->
queries
;
}
/**
/**
* getIterator
* getIterator
*
*
...
...
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