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
5de6c0a6
Commit
5de6c0a6
authored
Oct 01, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified object population mechanism
parent
ca213ac6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
79 deletions
+49
-79
Hydrate.php
lib/Doctrine/Hydrate.php
+49
-79
No files found.
lib/Doctrine/Hydrate.php
View file @
5de6c0a6
...
...
@@ -273,112 +273,82 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if
(
$this
->
aggregate
)
return
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
switch
(
count
(
$this
->
tables
))
:
case
0
:
throw
new
Doctrine_Exception
(
"No tables selected"
);
break
;
case
1
:
$keys
=
array_keys
(
$this
->
tables
);
$name
=
$this
->
tables
[
$keys
[
0
]]
->
getComponentName
();
if
(
count
(
$this
->
tables
)
==
0
)
throw
new
Doctrine_Exception
(
"No tables selected"
);
while
(
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
))
:
$keys
=
array_keys
(
$this
->
tables
);
$root
=
$keys
[
0
];
foreach
(
$data
as
$key
=>
$value
)
:
$e
=
explode
(
"__"
,
$key
);
if
(
count
(
$e
)
>
1
)
{
$previd
=
array
();
$data
[
end
(
$e
)]
=
$value
;
}
else
{
$data
[
$e
[
0
]]
=
$value
;
}
unset
(
$data
[
$key
]);
endforeach
;
$this
->
data
[
$name
][]
=
$data
;
endwhile
;
$coll
=
$this
->
getCollection
(
$root
);
$prev
[
$root
]
=
$coll
;
return
$this
->
getCollection
(
$keys
[
0
]);
break
;
default
:
if
(
$this
->
aggregate
)
$return
=
Doctrine
::
FETCH_ARRAY
;
$keys
=
array_keys
(
$this
->
tables
);
$root
=
$keys
[
0
];
$array
=
$this
->
parseData
(
$stmt
);
$previd
=
array
();
$coll
=
$this
->
getCollection
(
$root
);
$prev
[
$root
]
=
$coll
;
if
(
$this
->
aggregate
)
$return
=
Doctrine
::
FETCH_ARRAY
;
$array
=
$this
->
parseData
(
$stmt
);
if
(
$return
==
Doctrine
::
FETCH_ARRAY
)
return
$array
;
if
(
$return
==
Doctrine
::
FETCH_ARRAY
)
return
$array
;
foreach
(
$array
as
$data
)
{
/**
* remove duplicated data rows and map data into objects
*/
foreach
(
$data
as
$key
=>
$row
)
{
if
(
empty
(
$row
))
continue
;
foreach
(
$array
as
$data
)
{
/**
* remove duplicated data rows and map data into objects
*/
foreach
(
$data
as
$key
=>
$row
)
{
if
(
empty
(
$row
))
continue
;
$ids
=
$this
->
tables
[
$key
]
->
getIdentifier
();
$name
=
$key
;
$ids
=
$this
->
tables
[
$key
]
->
getIdentifier
();
$name
=
$key
;
if
(
$this
->
isIdentifiable
(
$row
,
$ids
))
{
if
(
$this
->
isIdentifiable
(
$row
,
$ids
))
{
$prev
=
$this
->
initRelated
(
$prev
,
$name
);
continue
;
}
$prev
=
$this
->
initRelated
(
$prev
,
$name
);
continue
;
}
if
(
!
isset
(
$previd
[
$name
]))
if
(
!
isset
(
$previd
[
$name
]))
$previd
[
$name
]
=
array
();
if
(
$previd
[
$name
]
!==
$row
)
{
// set internal data
$this
->
tables
[
$name
]
->
setData
(
$row
);
if
(
$previd
[
$name
]
!==
$row
)
{
// set internal data
// initialize a new record
$record
=
$this
->
tables
[
$name
]
->
getRecord
();
$this
->
tables
[
$name
]
->
setData
(
$row
);
// initialize a new record
$record
=
$this
->
tables
[
$name
]
->
getRecord
();
if
(
$name
==
$root
)
{
// add record into root collection
$coll
->
add
(
$record
);
unset
(
$previd
);
if
(
$name
==
$root
)
{
}
else
{
$prev
=
$this
->
addRelated
(
$prev
,
$name
,
$record
);
}
// add record into root collection
$coll
->
add
(
$record
);
unset
(
$previd
);
// following statement is needed to ensure that mappings
// are being done properly when the result set doesn't
// contain the rows in 'right order'
if
(
$prev
[
$name
]
!==
$record
)
$prev
[
$name
]
=
$record
;
}
$previd
[
$name
]
=
$row
;
}
else
{
$prev
=
$this
->
addRelated
(
$prev
,
$name
,
$record
);
}
// following statement is needed to ensure that mappings
// are being done properly when the result set doesn't
// contain the rows in 'right order'
if
(
$prev
[
$name
]
!==
$record
)
$prev
[
$name
]
=
$record
;
}
return
$coll
;
endswitch
;
$previd
[
$name
]
=
$row
;
}
}
return
$coll
;
}
/**
* initRelation
...
...
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