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
Hide 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 {
...
@@ -80,6 +80,7 @@ class Doctrine_DB extends PDO implements Countable, IteratorAggregate {
*/
*/
public
function
prepare
(
$query
)
{
public
function
prepare
(
$query
)
{
$this
->
queries
[]
=
$query
;
$this
->
queries
[]
=
$query
;
return
parent
::
prepare
(
$query
);
return
parent
::
prepare
(
$query
);
}
}
/**
/**
...
...
Doctrine/DataDict.php
View file @
bf5deba9
...
@@ -44,6 +44,10 @@ class Doctrine_DataDict {
...
@@ -44,6 +44,10 @@ class Doctrine_DataDict {
*/
*/
public
function
getADOType
(
$type
,
$length
)
{
public
function
getADOType
(
$type
,
$length
)
{
switch
(
$type
)
:
switch
(
$type
)
:
case
"array"
:
case
"a"
:
case
"object"
:
case
"o"
:
case
"string"
:
case
"string"
:
case
"s"
:
case
"s"
:
if
(
$length
<
255
)
if
(
$length
<
255
)
...
...
Doctrine/Manager.php
View file @
bf5deba9
...
@@ -40,6 +40,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -40,6 +40,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
Doctrine_Record
::
initNullObject
(
$this
->
null
);
Doctrine_Record
::
initNullObject
(
$this
->
null
);
Doctrine_Collection
::
initNullObject
(
$this
->
null
);
Doctrine_Collection
::
initNullObject
(
$this
->
null
);
Doctrine_Record_Iterator
::
initNullObject
(
$this
->
null
);
}
}
/**
/**
* @return Doctrine_Null
* @return Doctrine_Null
...
...
Doctrine/Record.php
View file @
bf5deba9
...
@@ -57,16 +57,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -57,16 +57,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var array $data the record data
* @var array $data the record data
*/
*/
protected
$data
=
array
();
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
* @var integer $state the state of this record
* @see STATE_* constants
* @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
* @var array $collections the collections this record is in
*/
*/
...
@@ -134,13 +133,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -134,13 +133,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$count
=
count
(
$this
->
data
);
$count
=
count
(
$this
->
data
);
// clean data array
// clean data array
$
cols
=
$
this
->
cleanData
();
$this
->
cleanData
();
$this
->
prepareIdentifiers
(
$exists
);
$this
->
prepareIdentifiers
(
$exists
);
if
(
!
$exists
)
{
if
(
!
$exists
)
{
if
(
$co
ls
>
0
)
if
(
$co
unt
>
0
)
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
else
else
$this
->
state
=
Doctrine_Record
::
STATE_TCLEAN
;
$this
->
state
=
Doctrine_Record
::
STATE_TCLEAN
;
...
@@ -164,10 +163,18 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -164,10 +163,18 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
/**
/**
* initNullObject
* initNullObject
*
* @param Doctrine_Null $null
*/
*/
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
public
static
function
initNullObject
(
Doctrine_Null
$null
)
{
self
::
$null
=
$null
;
self
::
$null
=
$null
;
}
}
/**
* @return Doctrine_Null
*/
public
static
function
getNullObject
()
{
return
self
::
$null
;
}
/**
/**
* setUp
* setUp
* implemented by child classes
* implemented by child classes
...
@@ -192,22 +199,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -192,22 +199,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* $data = array("name"=>"John","lastname" => array(),"id"=>1);
* $data = array("name"=>"John","lastname" => array(),"id"=>1);
*/
*/
private
function
cleanData
()
{
private
function
cleanData
()
{
$cols
=
0
;
$tmp
=
$this
->
data
;
$tmp
=
$this
->
data
;
$this
->
data
=
array
();
$this
->
data
=
array
();
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
if
(
!
isset
(
$tmp
[
$name
]))
{
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
data
[
$name
]
=
self
::
$null
;
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
}
else
{
$cols
++
;
$this
->
data
[
$name
]
=
$tmp
[
$name
];
$this
->
data
[
$name
]
=
$tmp
[
$name
];
}
}
}
}
return
$cols
;
}
}
/**
/**
* prepares identifiers
* prepares identifiers
...
@@ -251,9 +253,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -251,9 +253,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
table
=
$this
->
table
->
getComponentName
();
$this
->
table
=
$this
->
table
->
getComponentName
();
// unset all vars that won't need to be serialized
// unset all vars that won't need to be serialized
unset
(
$this
->
modified
);
unset
(
$this
->
associations
);
unset
(
$this
->
associations
);
unset
(
$this
->
state
);
unset
(
$this
->
collections
);
unset
(
$this
->
collections
);
unset
(
$this
->
references
);
unset
(
$this
->
references
);
unset
(
$this
->
originals
);
unset
(
$this
->
originals
);
...
@@ -262,6 +262,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -262,6 +262,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
->
data
as
$k
=>
$v
)
{
foreach
(
$this
->
data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Record
)
if
(
$v
instanceof
Doctrine_Record
)
$this
->
data
[
$k
]
=
array
();
$this
->
data
[
$k
]
=
array
();
elseif
(
$v
===
self
::
$null
)
unset
(
$this
->
data
[
$k
]);
}
}
return
array_keys
(
get_object_vars
(
$this
));
return
array_keys
(
get_object_vars
(
$this
));
...
@@ -273,10 +275,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -273,10 +275,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
* @return void
*/
*/
public
function
__wakeup
()
{
public
function
__wakeup
()
{
$this
->
modified
=
array
();
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$name
=
$this
->
table
;
$name
=
$this
->
table
;
$manager
=
Doctrine_Manager
::
getInstance
();
$manager
=
Doctrine_Manager
::
getInstance
();
...
@@ -405,6 +403,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -405,6 +403,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final
public
function
getData
()
{
final
public
function
getData
()
{
return
$this
->
data
;
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
* get
* returns a value of a property or a related component
* returns a value of a property or a related component
...
@@ -459,7 +474,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -459,7 +474,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
!
empty
(
$id
))
if
(
!
empty
(
$id
))
$value
=
$id
;
$value
=
$id
;
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
{
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
{
if
(
$this
->
data
[
$name
]
!==
$value
)
{
if
(
$this
->
data
[
$name
]
!==
$value
)
{
...
@@ -477,7 +492,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -477,7 +492,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
data
[
$name
]
=
$value
;
$this
->
data
[
$name
]
=
$value
;
$this
->
modified
[]
=
$name
;
$this
->
modified
[]
=
$name
;
}
}
}
}
/**
/**
...
@@ -658,10 +673,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -658,10 +673,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
/**
/**
* getIterator
* 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
()
{
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
data
);
return
new
Doctrine_Record_Iterator
(
$this
);
}
}
/**
/**
* saveAssociations
* saveAssociations
...
@@ -1112,7 +1127,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -1112,7 +1127,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
__call
(
$m
,
$a
)
{
public
function
__call
(
$m
,
$a
)
{
if
(
!
function_exists
(
$m
))
if
(
!
function_exists
(
$m
))
throw
new
Doctrine_Record_Exception
(
"unknown callback '
$m
'"
);
throw
new
Doctrine_Record_Exception
(
"unknown callback '
$m
'"
);
if
(
isset
(
$a
[
0
]))
{
if
(
isset
(
$a
[
0
]))
{
$column
=
$a
[
0
];
$column
=
$a
[
0
];
$a
[
0
]
=
$this
->
get
(
$column
);
$a
[
0
]
=
$this
->
get
(
$column
);
...
...
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 {
...
@@ -65,7 +65,9 @@ class Doctrine_Table extends Doctrine_Configurable {
* @var array $identityMap first level cache
* @var array $identityMap first level cache
*/
*/
private
$identityMap
=
array
();
private
$identityMap
=
array
();
/**
* @var Doctrine_Repository $repository record repository
*/
private
$repository
;
private
$repository
;
/**
/**
...
@@ -714,14 +716,20 @@ class Doctrine_Table extends Doctrine_Configurable {
...
@@ -714,14 +716,20 @@ class Doctrine_Table extends Doctrine_Configurable {
foreach
(
$key
as
$k
)
{
foreach
(
$key
as
$k
)
{
if
(
!
isset
(
$this
->
data
[
$k
]))
if
(
!
isset
(
$this
->
data
[
$k
]))
throw
new
Doctrine_Exception
(
"No primary key found"
);
throw
new
Doctrine_Exception
(
"No primary key found"
);
$id
[]
=
$this
->
data
[
$k
];
$id
[]
=
$this
->
data
[
$k
];
}
}
$id
=
implode
(
' '
,
$id
);
$id
=
implode
(
' '
,
$id
);
if
(
isset
(
$this
->
identityMap
[
$id
]))
if
(
isset
(
$this
->
identityMap
[
$id
]))
$record
=
$this
->
identityMap
[
$id
];
$record
=
$this
->
identityMap
[
$id
];
else
{
else
{
/**
if($this->createsChildren) {
}
*/
$record
=
new
$this
->
name
(
$this
);
$record
=
new
$this
->
name
(
$this
);
$this
->
identityMap
[
$id
]
=
$record
;
$this
->
identityMap
[
$id
]
=
$record
;
}
}
...
...
tests/QueryTestCase.class.php
View file @
bf5deba9
...
@@ -22,6 +22,12 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
...
@@ -22,6 +22,12 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
[
0
]
->
Email
->
address
,
'zYne@example.com'
);
$this
->
assertEqual
(
$users
[
0
]
->
Email
->
address
,
'zYne@example.com'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$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
()
{
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