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
d6565667
Commit
d6565667
authored
Apr 14, 2010
by
Jonathan H. Wage
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
ceb05e85
f3d91b9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
SingleScalarHydrator.php
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
+5
-1
QueryTest.php
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
+41
-1
No files found.
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
View file @
d6565667
...
...
@@ -36,7 +36,11 @@ class SingleScalarHydrator extends AbstractHydrator
{
$cache
=
array
();
$result
=
$this
->
_stmt
->
fetchAll
(
\PDO
::
FETCH_ASSOC
);
if
(
count
(
$result
)
>
1
||
count
(
$result
[
key
(
$result
)])
>
1
)
{
$num
=
count
(
$result
);
if
(
$num
==
0
)
{
throw
new
\Doctrine\ORM\NoResultException
;
}
else
if
(
$num
>
1
||
count
(
$result
[
key
(
$result
)])
>
1
)
{
throw
new
\Doctrine\ORM\NonUniqueResultException
;
}
$result
=
$this
->
_gatherScalarRowData
(
$result
[
key
(
$result
)],
$cache
);
...
...
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
View file @
d6565667
...
...
@@ -224,7 +224,47 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
public
function
testGetSingleResultThrowsExceptionOnNoResult
()
{
$this
->
_em
->
createQuery
(
"select a from Doctrine\Tests\Models\CMS\CmsArticle a"
)
->
getSingleResult
();
->
getSingleResult
();
}
/**
* @expectedException Doctrine\ORM\NoResultException
*/
public
function
testGetSingleScalarResultThrowsExceptionOnNoResult
()
{
$this
->
_em
->
createQuery
(
"select a from Doctrine\Tests\Models\CMS\CmsArticle a"
)
->
getSingleScalarResult
();
}
/**
* @expectedException Doctrine\ORM\NonUniqueResultException
*/
public
function
testGetSingleScalarResultThrowsExceptionOnNonUniqueResult
()
{
$user
=
new
CmsUser
;
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
$article1
=
new
CmsArticle
;
$article1
->
topic
=
"Doctrine 2"
;
$article1
->
text
=
"This is an introduction to Doctrine 2."
;
$user
->
addArticle
(
$article1
);
$article2
=
new
CmsArticle
;
$article2
->
topic
=
"Symfony 2"
;
$article2
->
text
=
"This is an introduction to Symfony 2."
;
$user
->
addArticle
(
$article2
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
persist
(
$article1
);
$this
->
_em
->
persist
(
$article2
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$this
->
_em
->
createQuery
(
"select a from Doctrine\Tests\Models\CMS\CmsArticle a"
)
->
getSingleScalarResult
();
}
public
function
testSupportsQueriesWithEntityNamespaces
()
...
...
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