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
6db25011
Commit
6db25011
authored
Nov 15, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added docs and enhanced fromArray()
parent
c97fc19d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
6 deletions
+49
-6
Collection.php
lib/Doctrine/Collection.php
+49
-6
No files found.
lib/Doctrine/Collection.php
View file @
6db25011
...
...
@@ -661,16 +661,33 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
$data
;
}
/**
* fromArray
*
* Populate a Doctrine_Collection from an array of data
*
* @param string $array
* @return void
*/
public
function
fromArray
(
$array
)
{
$data
=
array
();
foreach
(
$array
as
$row
)
{
$record
=
$this
->
_table
->
getRecord
();
$record
->
fromArray
(
$row
);
$this
[]
=
$record
;
foreach
(
$array
as
$rowKey
=>
$row
)
{
$this
[
$rowKey
]
->
fromArray
(
$row
);
}
}
/**
* exportTo
*
* Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $deep
* @return void
*/
public
function
exportTo
(
$type
,
$deep
=
false
)
{
if
(
$type
==
'array'
)
{
...
...
@@ -679,6 +696,16 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
Doctrine_Parser
::
dump
(
$this
->
toArray
(
$deep
,
true
),
$type
);
}
}
/**
* importFrom
*
* Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $data
* @return void
*/
public
function
importFrom
(
$type
,
$data
)
{
if
(
$type
==
'array'
)
{
...
...
@@ -687,10 +714,22 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
$this
->
fromArray
(
Doctrine_Parser
::
load
(
$data
,
$type
));
}
}
/**
* getDeleteDiff
*
* @return void
*/
public
function
getDeleteDiff
()
{
return
array_udiff
(
$this
->
_snapshot
,
$this
->
data
,
array
(
$this
,
"compareRecords"
));
}
/**
* getInsertDiff
*
* @return void
*/
public
function
getInsertDiff
()
{
return
array_udiff
(
$this
->
data
,
$this
->
_snapshot
,
array
(
$this
,
"compareRecords"
));
...
...
@@ -702,7 +741,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
protected
function
compareRecords
(
$a
,
$b
)
{
if
(
$a
->
getOid
()
==
$b
->
getOid
())
return
0
;
if
(
$a
->
getOid
()
==
$b
->
getOid
())
{
return
0
;
}
return
(
$a
->
getOid
()
>
$b
->
getOid
())
?
1
:
-
1
;
}
...
...
@@ -719,6 +761,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
$conn
==
null
)
{
$conn
=
$this
->
_table
->
getConnection
();
}
$conn
->
beginTransaction
();
$conn
->
transaction
->
addCollection
(
$this
);
...
...
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