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
067fe93c
Commit
067fe93c
authored
May 29, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
200% speed increase for get/set with with new Null object
parent
20990ed2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
14 deletions
+43
-14
Collection.class.php
classes/Collection.class.php
+10
-0
Batch.class.php
classes/Collection/Batch.class.php
+2
-1
Manager.class.php
classes/Manager.class.php
+15
-1
Record.class.php
classes/Record.class.php
+14
-10
run.php
tests/run.php
+2
-2
No files found.
classes/Collection.class.php
View file @
067fe93c
...
...
@@ -41,6 +41,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @var mixed $generator
*/
protected
$generator
;
/**
* @var Doctrine_Null $null used for extremely fast SQL null value testing
*/
protected
static
$null
;
/**
* constructor
...
...
@@ -53,6 +57,12 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$this
->
generator
=
new
Doctrine_IndexGenerator
(
$name
);
}
}
/**
* initNullObject
*/
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
self
::
$null
=
$null
;
}
/**
* @return object Doctrine_Table
*/
...
...
classes/Collection/Batch.class.php
View file @
067fe93c
...
...
@@ -80,7 +80,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
$proxies
=
array
();
for
(
$i
=
$e
;
$i
<
$e2
&&
$i
<
$this
->
count
();
$i
++
)
:
if
(
is_object
(
$this
->
data
[
$i
])
)
if
(
$this
->
data
[
$i
]
instanceof
Doctrine_Record
)
$id
=
$this
->
data
[
$i
]
->
getID
();
elseif
(
is_array
(
$this
->
data
[
$i
]))
$id
=
$this
->
data
[
$i
][
$identifier
];
...
...
@@ -120,6 +120,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
return
false
;
}
}
/**
* get
* @param mixed $key the key of the record
...
...
classes/Manager.class.php
View file @
067fe93c
...
...
@@ -25,13 +25,27 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
/**
* @var string $root root directory
*/
private
$root
;
private
$root
;
/**
* @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking
*/
private
$null
;
/**
* constructor
*/
private
function
__construct
()
{
$this
->
root
=
dirname
(
__FILE__
);
$this
->
null
=
new
Doctrine_Null
;
Doctrine_Record
::
initNullObject
(
$this
->
null
);
Doctrine_Collection
::
initNullObject
(
$this
->
null
);
}
/**
* @return Doctrine_Null
*/
final
public
function
getNullObject
()
{
return
$this
->
null
;
}
/**
* setDefaultAttributes
...
...
classes/Record.class.php
View file @
067fe93c
...
...
@@ -84,9 +84,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
private
static
$index
=
1
;
/**
* @var Doctrine_Null $nullObject a Doctrine_Null object used for SQL null value testing
* @var Doctrine_Null $nullObject a Doctrine_Null object used for extremely fast
* SQL null value testing
*/
private
static
$null
Object
;
private
static
$null
;
/**
* @var integer $oid object identifier
*/
...
...
@@ -164,8 +165,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/**
* initNullObject
*/
public
static
function
initNullObject
()
{
self
::
$null
Object
=
new
Doctrine_N
ull
;
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
self
::
$null
=
$n
ull
;
}
/**
* setUp
...
...
@@ -198,7 +199,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
data
[
$name
]
=
array
()
;
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
$cols
++
;
...
...
@@ -231,7 +232,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
id
=
array
();
foreach
(
$names
as
$name
)
{
$this
->
id
[
$name
]
=
isset
(
$this
->
data
[
$name
])
?
$this
->
data
[
$name
]
:
null
;
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
$this
->
id
[
$name
]
=
null
;
else
$this
->
id
[
$name
]
=
$this
->
data
[
$name
];
}
break
;
endswitch
;
...
...
@@ -408,8 +412,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
get
(
$name
)
{
if
(
isset
(
$this
->
data
[
$name
]))
{
// check if the property is n
ot loaded (= it is an empty array
)
if
(
is_array
(
$this
->
data
[
$name
])
)
{
// check if the property is n
ull (= it is the Doctrine_Null object located in self::$null
)
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
{
// no use trying to load the data from database if the Doctrine_Record is not a proxy
if
(
$this
->
state
==
Doctrine_Record
::
STATE_PROXY
)
{
...
...
@@ -423,7 +427,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
}
if
(
is_array
(
$this
->
data
[
$name
])
)
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
return
null
;
}
return
$this
->
data
[
$name
];
...
...
@@ -453,7 +457,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
$id
;
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
!
is_array
(
$this
->
data
[
$name
])
)
{
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
{
if
(
$this
->
data
[
$name
]
!==
$value
)
{
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
...
...
tests/run.php
View file @
067fe93c
...
...
@@ -24,12 +24,12 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
//$test->addTestCase(new Sensei_UnitTestCase());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_TableTestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_ManagerTestCase
());
...
...
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