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
cc56542d
Commit
cc56542d
authored
Jun 04, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
a0a9df9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
29 deletions
+33
-29
Hydrate.php
lib/Doctrine/Hydrate.php
+33
-29
No files found.
lib/Doctrine/Hydrate.php
View file @
cc56542d
...
...
@@ -800,6 +800,10 @@ class Doctrine_Hydrate implements Serializable
$parse
=
true
;
foreach
(
$data
as
$key
=>
$value
)
{
// The following little cache solution ensures that field aliases are
// parsed only once. This increases speed on large result sets by an order
// of magnitude.
if
(
!
isset
(
$cache
[
$key
]))
{
$e
=
explode
(
'__'
,
$key
);
$cache
[
$key
][
'field'
]
=
$field
=
strtolower
(
array_pop
(
$e
));
...
...
@@ -872,21 +876,8 @@ class Doctrine_Hydrate implements Serializable
$coll
=&
$prev
[
$parent
][
$componentAlias
];
}
if
(
$index
!==
false
)
{
$prev
[
$alias
]
=&
$coll
[
$index
];
}
else
{
// first check the count (we do not want to get the last element
// of an empty collection/array)
if
(
count
(
$coll
)
>
0
)
{
// check the type
if
(
is_array
(
$coll
))
{
end
(
$coll
);
$prev
[
$alias
]
=&
$coll
[
key
(
$coll
)];
}
else
{
$prev
[
$alias
]
=
$coll
->
getLast
();
}
}
}
$this
->
_setLastElement
(
$prev
,
$coll
,
$index
,
$alias
);
$currData
[
$alias
]
=
array
();
$identifiable
[
$alias
]
=
null
;
}
...
...
@@ -948,20 +939,7 @@ class Doctrine_Hydrate implements Serializable
$coll
=&
$prev
[
$parent
][
$componentAlias
];
}
if
(
$index
!==
false
)
{
$prev
[
$alias
]
=&
$coll
[
$index
];
}
else
{
// first check the count (we do not want to get the last element
// of an empty collection/array)
if
(
count
(
$coll
)
>
0
)
{
if
(
is_array
(
$coll
))
{
end
(
$coll
);
$prev
[
$alias
]
=&
$coll
[
key
(
$coll
)];
}
else
{
$prev
[
$alias
]
=
$coll
->
getLast
();
}
}
}
$this
->
_setLastElement
(
$prev
,
$coll
,
$index
,
$alias
);
$index
=
false
;
$currData
[
$alias
]
=
array
();
unset
(
$identifiable
[
$alias
]);
...
...
@@ -972,6 +950,32 @@ class Doctrine_Hydrate implements Serializable
$stmt
->
closeCursor
();
return
$array
;
}
/**
* _setLastElement
*
* sets the last element of given data array / collection
* as previous element
*
* @param boolean|integer $index
* @return void
*/
public
function
_setLastElement
(
&
$prev
,
&
$coll
,
$index
,
$alias
)
{
if
(
$index
!==
false
)
{
$prev
[
$alias
]
=&
$coll
[
$index
];
}
else
{
// first check the count (we do not want to get the last element
// of an empty collection/array)
if
(
count
(
$coll
)
>
0
)
{
if
(
is_array
(
$coll
))
{
end
(
$coll
);
$prev
[
$alias
]
=&
$coll
[
key
(
$coll
)];
}
else
{
$prev
[
$alias
]
=
$coll
->
getLast
();
}
}
}
}
/**
* @return string returns a string representation of this object
*/
...
...
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