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
54010a55
Commit
54010a55
authored
Feb 09, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-309 - Allow multiple IteratbleResult instances and work on them concurrently.
parent
bf327759
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
18 deletions
+107
-18
AbstractQuery.php
lib/Doctrine/ORM/AbstractQuery.php
+1
-1
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+33
-17
DDC309Test.php
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php
+73
-0
No files found.
lib/Doctrine/ORM/AbstractQuery.php
View file @
54010a55
...
...
@@ -456,7 +456,7 @@ abstract class AbstractQuery
*/
public
function
iterate
(
array
$params
=
array
(),
$hydrationMode
=
self
::
HYDRATE_OBJECT
)
{
return
$this
->
_em
->
get
Hydrator
(
$this
->
_hydrationMode
)
->
iterate
(
return
$this
->
_em
->
new
Hydrator
(
$this
->
_hydrationMode
)
->
iterate
(
$this
->
_doExecute
(
$params
,
$hydrationMode
),
$this
->
_resultSetMapping
);
}
...
...
lib/Doctrine/ORM/EntityManager.php
View file @
54010a55
...
...
@@ -510,31 +510,47 @@ class EntityManager
/**
* Gets a hydrator for the given hydration mode.
*
* @param $hydrationMode
* This method caches the hydrator instances which is used for all queries that don't
* selectively iterate over the result.
*
* @param int $hydrationMode
* @return Doctrine\ORM\Internal\Hydration\AbstractHydrator
*/
public
function
getHydrator
(
$hydrationMode
)
{
if
(
!
isset
(
$this
->
_hydrators
[
$hydrationMode
]))
{
switch
(
$hydrationMode
)
{
case
Query
::
HYDRATE_OBJECT
:
$this
->
_hydrators
[
$hydrationMode
]
=
new
Internal\Hydration\ObjectHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_ARRAY
:
$this
->
_hydrators
[
$hydrationMode
]
=
new
Internal\Hydration\ArrayHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_SCALAR
:
$this
->
_hydrators
[
$hydrationMode
]
=
new
Internal\Hydration\ScalarHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_SINGLE_SCALAR
:
$this
->
_hydrators
[
$hydrationMode
]
=
new
Internal\Hydration\SingleScalarHydrator
(
$this
);
break
;
default
:
throw
ORMException
::
invalidHydrationMode
(
$hydrationMode
);
}
$this
->
_hydrators
[
$hydrationMode
]
=
$this
->
newHydrator
(
$hydrationMode
);
}
return
$this
->
_hydrators
[
$hydrationMode
];
}
/**
* Create a new instance for the given hydration mode.
*
* @param int $hydrationMode
* @return Doctrine\ORM\Internal\Hydration\AbstractHydrator
*/
public
function
newHydrator
(
$hydrationMode
)
{
switch
(
$hydrationMode
)
{
case
Query
::
HYDRATE_OBJECT
:
$hydrator
=
new
Internal\Hydration\ObjectHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_ARRAY
:
$hydrator
=
new
Internal\Hydration\ArrayHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_SCALAR
:
$hydrator
=
new
Internal\Hydration\ScalarHydrator
(
$this
);
break
;
case
Query
::
HYDRATE_SINGLE_SCALAR
:
$hydrator
=
new
Internal\Hydration\SingleScalarHydrator
(
$this
);
break
;
default
:
throw
ORMException
::
invalidHydrationMode
(
$hydrationMode
);
}
return
$hydrator
;
}
/**
* Gets the proxy factory used by the EntityManager to create entity proxies.
*
...
...
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php
0 → 100644
View file @
54010a55
<?php
namespace
Doctrine\Tests\ORM\Functional\Ticket
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
DDC309Test
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC309Country'
),
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC309User'
),
));
}
public
function
testTwoIterateHydrations
()
{
$c1
=
new
DDC309Country
();
$c2
=
new
DDC309Country
();
$u1
=
new
DDC309User
();
$u2
=
new
DDC309User
();
$this
->
_em
->
persist
(
$c1
);
$this
->
_em
->
persist
(
$c2
);
$this
->
_em
->
persist
(
$u1
);
$this
->
_em
->
persist
(
$u2
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$q
=
$this
->
_em
->
createQuery
(
'SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c'
)
->
iterate
();
$c
=
$q
->
next
();
$this
->
assertEquals
(
1
,
$c
[
0
]
->
id
);
$r
=
$this
->
_em
->
createQuery
(
'SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u'
)
->
iterate
();
$u
=
$r
->
next
();
// This line breaks
$this
->
assertEquals
(
1
,
$u
[
0
]
->
id
);
$c
=
$q
->
next
();
$u
=
$r
->
next
();
$this
->
assertEquals
(
2
,
$c
[
0
]
->
id
);
$this
->
assertEquals
(
2
,
$u
[
0
]
->
id
);
}
}
/**
* @Entity
*/
class
DDC309Country
{
/**
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public
$id
;
}
/**
* @Entity
*/
class
DDC309User
{
/**
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public
$id
;
}
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