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
bf5deba9
Commit
bf5deba9
authored
Jun 01, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New datatypes: array and object
parent
54801dde
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
27 deletions
+104
-27
DB.php
Doctrine/DB.php
+1
-0
DataDict.php
Doctrine/DataDict.php
+4
-0
Manager.php
Doctrine/Manager.php
+1
-0
Record.php
Doctrine/Record.php
+40
-25
Iterator.php
Doctrine/Record/Iterator.php
+42
-0
Table.php
Doctrine/Table.php
+10
-2
QueryTestCase.class.php
tests/QueryTestCase.class.php
+6
-0
No files found.
Doctrine/DB.php
View file @
bf5deba9
...
...
@@ -80,6 +80,7 @@ class Doctrine_DB extends PDO implements Countable, IteratorAggregate {
*/
public
function
prepare
(
$query
)
{
$this
->
queries
[]
=
$query
;
return
parent
::
prepare
(
$query
);
}
/**
...
...
Doctrine/DataDict.php
View file @
bf5deba9
...
...
@@ -44,6 +44,10 @@ class Doctrine_DataDict {
*/
public
function
getADOType
(
$type
,
$length
)
{
switch
(
$type
)
:
case
"array"
:
case
"a"
:
case
"object"
:
case
"o"
:
case
"string"
:
case
"s"
:
if
(
$length
<
255
)
...
...
Doctrine/Manager.php
View file @
bf5deba9
...
...
@@ -40,6 +40,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine_Record
::
initNullObject
(
$this
->
null
);
Doctrine_Collection
::
initNullObject
(
$this
->
null
);
Doctrine_Record_Iterator
::
initNullObject
(
$this
->
null
);
}
/**
* @return Doctrine_Null
...
...
Doctrine/Record.php
View file @
bf5deba9
...
...
@@ -57,16 +57,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var array $data the record data
*/
protected
$data
=
array
();
/**
* @var array $modified an array containing properties that have been modified
*/
private
$modified
=
array
();
/**
* @var integer $state the state of this record
* @see STATE_* constants
*/
private
$state
;
protected
$state
;
/**
* @var array $modified an array containing properties that have been modified
*/
protected
$modified
=
array
();
/**
* @var array $collections the collections this record is in
*/
...
...
@@ -134,13 +133,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$count
=
count
(
$this
->
data
);
// clean data array
$
cols
=
$
this
->
cleanData
();
$this
->
cleanData
();
$this
->
prepareIdentifiers
(
$exists
);
if
(
!
$exists
)
{
if
(
$co
ls
>
0
)
if
(
$co
unt
>
0
)
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
else
$this
->
state
=
Doctrine_Record
::
STATE_TCLEAN
;
...
...
@@ -164,10 +163,18 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
/**
* initNullObject
*
* @param Doctrine_Null $null
*/
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
self
::
$null
=
$null
;
}
/**
* @return Doctrine_Null
*/
public
static
function
getNullObject
()
{
return
self
::
$null
;
}
/**
* setUp
* implemented by child classes
...
...
@@ -192,7 +199,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* $data = array("name"=>"John","lastname" => array(),"id"=>1);
*/
private
function
cleanData
()
{
$cols
=
0
;
$tmp
=
$this
->
data
;
$this
->
data
=
array
();
...
...
@@ -200,14 +206,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
$cols
++
;
$this
->
data
[
$name
]
=
$tmp
[
$name
];
}
}
return
$cols
;
}
/**
* prepares identifiers
...
...
@@ -251,9 +253,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
table
=
$this
->
table
->
getComponentName
();
// unset all vars that won't need to be serialized
unset
(
$this
->
modified
);
unset
(
$this
->
associations
);
unset
(
$this
->
state
);
unset
(
$this
->
collections
);
unset
(
$this
->
references
);
unset
(
$this
->
originals
);
...
...
@@ -262,6 +262,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
->
data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Record
)
$this
->
data
[
$k
]
=
array
();
elseif
(
$v
===
self
::
$null
)
unset
(
$this
->
data
[
$k
]);
}
return
array_keys
(
get_object_vars
(
$this
));
...
...
@@ -273,10 +275,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
public
function
__wakeup
()
{
$this
->
modified
=
array
();
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$name
=
$this
->
table
;
$manager
=
Doctrine_Manager
::
getInstance
();
...
...
@@ -405,6 +403,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final
public
function
getData
()
{
return
$this
->
data
;
}
/**
* rawGet
* returns the value of a property, if the property is not yet loaded
* this method does NOT load it
*
* @param $name name of the property
* @return mixed
*/
public
function
rawGet
(
$name
)
{
if
(
!
isset
(
$this
->
data
[
$name
]))
throw
new
InvalidKeyException
();
if
(
$this
->
data
[
$name
]
==
self
::
$null
)
return
null
;
return
$this
->
data
[
$name
];
}
/**
* get
* returns a value of a property or a related component
...
...
@@ -658,10 +673,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
/**
* getIterator
* @return
ArrayIterator an Array
Iterator that iterates through the data
* @return
Doctrine_Record_Iterator a Doctrine_Record_
Iterator that iterates through the data
*/
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
data
);
return
new
Doctrine_Record_Iterator
(
$this
);
}
/**
* saveAssociations
...
...
Doctrine/Record/Iterator.php
0 → 100644
View file @
bf5deba9
<?php
class
Doctrine_Record_Iterator
extends
ArrayIterator
{
/**
* @var Doctrine_Record $record
*/
private
$record
;
/**
* @var Doctrine_Null $null
*/
private
static
$null
;
/**
* constructor
*
* @param Doctrine_Record $record
*/
public
function
__construct
(
Doctrine_Record
$record
)
{
$this
->
record
=
$record
;
parent
::
__construct
(
$record
->
getData
());
}
/**
* initNullObject
*
* @param Doctrine_Null $null
*/
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
self
::
$null
=
$null
;
}
/**
* current
*
* @return mixed
*/
public
function
current
()
{
$value
=
parent
::
current
();
if
(
$value
==
self
::
$null
)
return
null
;
else
return
$value
;
}
}
?>
Doctrine/Table.php
View file @
bf5deba9
...
...
@@ -65,7 +65,9 @@ class Doctrine_Table extends Doctrine_Configurable {
* @var array $identityMap first level cache
*/
private
$identityMap
=
array
();
/**
* @var Doctrine_Repository $repository record repository
*/
private
$repository
;
/**
...
...
@@ -717,11 +719,17 @@ class Doctrine_Table extends Doctrine_Configurable {
$id
[]
=
$this
->
data
[
$k
];
}
$id
=
implode
(
' '
,
$id
);
if
(
isset
(
$this
->
identityMap
[
$id
]))
$record
=
$this
->
identityMap
[
$id
];
else
{
/**
if($this->createsChildren) {
}
*/
$record
=
new
$this
->
name
(
$this
);
$this
->
identityMap
[
$id
]
=
$record
;
}
...
...
tests/QueryTestCase.class.php
View file @
bf5deba9
...
...
@@ -22,6 +22,12 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
[
0
]
->
Email
->
address
,
'zYne@example.com'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
get_class
(
$users
[
1
]
->
Email
),
'Email'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
Email
->
address
,
'arnold@example.com'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
}
public
function
testLazyPropertyFetchingWithMultipleColumns
()
{
...
...
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