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
bd612715
Commit
bd612715
authored
Aug 28, 2007
by
jackbravo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toArray now can return also the record relations
parent
11bae777
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
Collection.php
lib/Doctrine/Collection.php
+18
-2
Record.php
lib/Doctrine/Record.php
+7
-1
No files found.
lib/Doctrine/Collection.php
View file @
bd612715
...
...
@@ -580,9 +580,25 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
$this
;
}
public
function
toArray
()
/**
* toArray
* Mimics the result of a $query->execute(array(), Doctrine::FETCH_ARRAY);
*
* @param boolean $deep
*/
public
function
toArray
(
$deep
=
false
)
{
return
$this
->
data
;
if
(
$deep
)
{
$data
=
array
();
foreach
(
$this
->
data
as
$key
=>
$record
)
{
$data
[
$key
]
=
$record
->
toArray
(
$deep
);
}
return
$data
;
}
else
{
// this is preserved for backwards compatibility
// but could be replaced with above code
return
$this
->
data
;
}
}
public
function
getDeleteDiff
()
{
...
...
lib/Doctrine/Record.php
View file @
bd612715
...
...
@@ -1111,9 +1111,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* toArray
* returns the record as an array
*
* @param boolean $deep - Return also the relations
* @return array
*/
public
function
toArray
()
public
function
toArray
(
$deep
=
false
)
{
$a
=
array
();
...
...
@@ -1127,6 +1128,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$i
=
$this
->
_table
->
getIdentifier
();
$a
[
$i
]
=
$this
->
getIncremented
();
}
if
(
$deep
)
{
foreach
(
$this
->
_references
as
$key
=>
$relation
)
{
$a
[
$key
]
=
$relation
->
toArray
(
$deep
);
}
}
return
array_merge
(
$a
,
$this
->
_values
);
}
/**
...
...
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