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
78b06ef3
Commit
78b06ef3
authored
Jan 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
0bafdb66
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
11 deletions
+106
-11
Event.php
lib/Doctrine/Db/Event.php
+3
-0
Profiler.php
lib/Doctrine/Db/Profiler.php
+84
-7
Table.php
lib/Doctrine/Table.php
+19
-4
No files found.
lib/Doctrine/Db/Event.php
View file @
78b06ef3
...
...
@@ -48,11 +48,14 @@ class Doctrine_Db_Event
protected
$endedMicrotime
;
public
function
__construct
(
$invoker
,
$type
,
$query
=
null
)
{
$this
->
invoker
=
$invoker
;
$this
->
type
=
$type
;
$this
->
query
=
$query
;
}
public
function
getQuery
()
{
...
...
lib/Doctrine/Db/Profiler.php
View file @
78b06ef3
...
...
@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Overloadable');
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Db_Profiler
implements
Doctrine_Overloadabl
e
class
Doctrine_Db_Profiler
extends
Doctrine_Access
implements
Doctrine_Overloadable
,
IteratorAggregat
e
{
/**
* @param array $listeners an array containing all availible listeners
...
...
@@ -47,6 +47,21 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable
* @param array $events an array containing all listened events
*/
private
$events
=
array
();
/**
* constructor
*/
public
function
__construct
()
{
}
/**
* setFilterQueryType
*
* @param integer $filter
* @return boolean
*/
public
function
setFilterQueryType
()
{
}
/**
* method overloader
* this method is used for invoking different listeners, for the full
...
...
@@ -55,7 +70,7 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable
* @param string $m the name of the method
* @param array $a method arguments
* @see Doctrine_Db_EventListener
* @return
void
* @return
boolean
*/
public
function
__call
(
$m
,
$a
)
{
...
...
@@ -64,21 +79,83 @@ class Doctrine_Db_Profiler implements Doctrine_Overloadable
throw
new
Doctrine_Db_Profiler_Exception
(
"Couldn't listen event. Event should be an instance of Doctrine_Db_Event."
);
}
// event methods should start with 'on'
if
(
substr
(
$m
,
0
,
2
)
!==
'on'
)
{
throw
new
Doctrine_Db_Profiler_Exception
(
"Couldn't invoke listener
$m
."
);
throw
new
Doctrine_Db_Profiler_Exception
(
"Couldn't invoke listener
:"
.
$m
);
}
if
(
substr
(
$m
,
2
,
3
)
===
'Pre'
&&
in_array
(
strtolower
(
substr
(
$m
,
3
)),
$this
->
listeners
))
{
if
(
substr
(
$m
,
2
,
3
)
===
'Pre'
&&
substr
(
$m
,
2
,
7
)
!==
'Prepare'
)
{
if
(
!
in_array
(
strtolower
(
substr
(
$m
,
5
)),
$this
->
listeners
))
{
throw
new
Doctrine_Db_Profiler_Exception
(
"Couldn't invoke listener :"
.
$m
);
}
// pre-event listener found
$a
[
0
]
->
start
();
if
(
!
in_array
(
$a
[
0
],
$this
->
events
,
true
))
{
$this
->
events
[]
=
$a
[
0
];
}
}
else
{
if
(
!
in_array
(
strtolower
(
substr
(
$m
,
2
)),
$this
->
listeners
))
{
throw
new
Doctrine_Db_Profiler_Exception
(
"Couldn't invoke listener :"
.
$m
);
}
// after-event listener found
$a
[
0
]
->
end
();
}
$this
->
events
[]
=
$a
[
0
];
/**
* If filtering by query type is enabled, only keep the query if
* it was one of the allowed types.
*/
if
(
!
is_null
(
$this
->
filterTypes
))
{
if
(
!
(
$a
[
0
]
->
getQueryType
()
&
$this
->
_filterTypes
))
{
return
false
;
}
}
return
true
;
}
/**
* get
*
* @param mixed $key
* @return Doctrine_Event
*/
public
function
get
(
$key
)
{
if
(
isset
(
$this
->
events
[
$key
]))
{
return
$this
->
events
[
$key
];
}
return
null
;
}
/**
* getAll
* returns all profiled events as an array
*
* @return array all events in an array
*/
public
function
getAll
()
{
return
$this
->
events
;
}
/**
* getIterator
* returns an iterator that iterates through the logged events
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
events
);
}
/**
* pop the last event from the event stack
*
* @return Doctrine_Db_Event
*/
public
function
pop
()
{
return
array_pop
(
$this
->
events
);
}
/**
* Get the Doctrine_Db_Event object for the last query that was run, regardless if it has
* ended or not. If the event has not ended, it's end time will be Null.
...
...
lib/Doctrine/Table.php
View file @
78b06ef3
...
...
@@ -217,18 +217,26 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
$found
)
break
;
$e2
=
explode
(
":"
,
$option
);
$e2
=
explode
(
':'
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
{
case
"autoincrement"
:
case
'autoincrement'
:
case
'autoinc'
:
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$found
=
true
;
break
;
case
"seq"
:
case
'seq'
:
case
'sequence'
:
$this
->
identifierType
=
Doctrine_Identifier
::
SEQUENCE
;
$found
=
true
;
if
(
$value
)
{
$this
->
options
[
'sequenceName'
]
=
$value
;
}
else
{
$this
->
options
[
'sequenceName'
]
=
$this
->
conn
->
getSequenceName
(
$this
->
options
[
'tableName'
]);
}
break
;
};
}
}
if
(
!
isset
(
$this
->
identifierType
))
{
$this
->
identifierType
=
Doctrine_Identifier
::
NORMAL
;
...
...
@@ -332,16 +340,19 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
/**
* setColumn
*
* @param string $name
* @param string $type
* @param integer $length
* @param mixed $options
* @throws Doctrine_Table_Exception if trying use wrongly typed parameter
* @return void
*/
final
public
function
setColumn
(
$name
,
$type
,
$length
=
null
,
$options
=
array
())
{
if
(
is_string
(
$options
))
{
$options
=
explode
(
'|'
,
$options
);
}
foreach
(
$options
as
$k
=>
$option
)
{
if
(
is_numeric
(
$k
))
{
if
(
!
empty
(
$option
))
{
...
...
@@ -354,6 +365,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
$length
==
null
)
$length
=
2147483647
;
if
((
string
)
(
int
)
$length
!==
(
string
)
$length
)
{
throw
new
Doctrine_Table_Exception
(
'Invalid argument given for column length'
);
}
$this
->
columns
[
$name
]
=
array
(
$type
,
$length
,
$options
);
...
...
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