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
95434d72
Commit
95434d72
authored
May 29, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DQL: Multiple related component fetching
parent
5d67e0aa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
8 deletions
+78
-8
Query.class.php
classes/Query.class.php
+7
-4
QueryTestCase.class.php
tests/QueryTestCase.class.php
+69
-2
run.php
tests/run.php
+2
-2
No files found.
classes/Query.class.php
View file @
95434d72
...
@@ -254,8 +254,11 @@ class Doctrine_Query extends Doctrine_Access {
...
@@ -254,8 +254,11 @@ class Doctrine_Query extends Doctrine_Access {
}
}
$q
.=
implode
(
", "
,
$a
);
$q
.=
implode
(
", "
,
$a
);
if
(
!
empty
(
$this
->
parts
[
'join'
]))
if
(
!
empty
(
$this
->
parts
[
'join'
]))
{
$q
.=
" "
.
implode
(
' '
,
$this
->
parts
[
"join"
]);
foreach
(
$this
->
parts
[
'join'
]
as
$part
)
{
$q
.=
" "
.
implode
(
' '
,
$part
);
}
}
$this
->
applyInheritance
();
$this
->
applyInheritance
();
if
(
!
empty
(
$this
->
parts
[
"where"
]))
if
(
!
empty
(
$this
->
parts
[
"where"
]))
...
@@ -931,10 +934,10 @@ class Doctrine_Query extends Doctrine_Access {
...
@@ -931,10 +934,10 @@ class Doctrine_Query extends Doctrine_Access {
switch
(
$mark
)
:
switch
(
$mark
)
:
case
":"
:
case
":"
:
$this
->
parts
[
"join"
][
$tname
]
=
"INNER JOIN "
.
$tname2
.
" ON "
.
$tname
.
"."
.
$fk
->
getLocal
()
.
" = "
.
$tname2
.
"."
.
$fk
->
getForeign
();
$this
->
parts
[
"join"
][
$tname
]
[]
=
"INNER JOIN "
.
$tname2
.
" ON "
.
$tname
.
"."
.
$fk
->
getLocal
()
.
" = "
.
$tname2
.
"."
.
$fk
->
getForeign
();
break
;
break
;
case
"."
:
case
"."
:
$this
->
parts
[
"join"
][
$tname
]
=
"LEFT JOIN "
.
$tname2
.
" ON "
.
$tname
.
"."
.
$fk
->
getLocal
()
.
" = "
.
$tname2
.
"."
.
$fk
->
getForeign
();
$this
->
parts
[
"join"
][
$tname
]
[]
=
"LEFT JOIN "
.
$tname2
.
" ON "
.
$tname
.
"."
.
$fk
->
getLocal
()
.
" = "
.
$tname2
.
"."
.
$fk
->
getForeign
();
break
;
break
;
endswitch
;
endswitch
;
...
...
tests/QueryTestCase.class.php
View file @
95434d72
...
@@ -8,6 +8,73 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
...
@@ -8,6 +8,73 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
parent
::
prepareTables
();
parent
::
prepareTables
();
}
}
public
function
testMultipleFetching
()
{
$count
=
$this
->
dbh
->
count
();
$this
->
session
->
getTable
(
'User'
)
->
clear
();
$this
->
session
->
getTable
(
'Email'
)
->
clear
();
$this
->
session
->
getTable
(
'Phonenumber'
)
->
clear
();
$users
=
$this
->
query
->
from
(
"User-l.Phonenumber-i, User-l:Email-i"
)
->
execute
();
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
count
(
$users
),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
Phonenumber
->
count
(),
1
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
0
]
->
Phonenumber
[
0
]
->
phonenumber
,
"123 123"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
->
count
(),
3
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
0
]
->
phonenumber
,
"123 123"
);
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
1
]
->
phonenumber
,
"456 456"
);
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
2
]
->
phonenumber
,
"789 789"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
7
]
->
Phonenumber
->
count
(),
1
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
7
]
->
Phonenumber
[
0
]
->
phonenumber
,
"111 567 333"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertTrue
(
$users
[
0
]
->
Email
instanceof
Email
);
$this
->
assertEqual
(
$users
[
0
]
->
Email
->
address
,
"zYne@example.com"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
0
]
->
email_id
,
$users
[
0
]
->
Email
->
id
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertTrue
(
$users
[
1
]
->
Email
instanceof
Email
);
$this
->
assertEqual
(
$users
[
1
]
->
Email
->
address
,
"arnold@example.com"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
email_id
,
$users
[
1
]
->
Email
->
id
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
}
public
function
testForeignKeyRelationFetching
()
{
$count
=
$this
->
dbh
->
count
();
$users
=
$this
->
query
->
from
(
"User-l.Phonenumber-i"
)
->
execute
();
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
count
(
$users
),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
Phonenumber
->
count
(),
1
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
0
]
->
Phonenumber
[
0
]
->
phonenumber
,
"123 123"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
->
count
(),
3
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
0
]
->
phonenumber
,
"123 123"
);
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
1
]
->
phonenumber
,
"456 456"
);
$this
->
assertEqual
(
$users
[
1
]
->
Phonenumber
[
2
]
->
phonenumber
,
"789 789"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
7
]
->
Phonenumber
->
count
(),
1
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
7
]
->
Phonenumber
[
0
]
->
phonenumber
,
"111 567 333"
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$users
[
0
]
->
name
,
"zYne"
);
$this
->
assertEqual
((
$count
+
2
),
$this
->
dbh
->
count
());
}
public
function
testOneToOneRelationFetching
()
{
public
function
testOneToOneRelationFetching
()
{
$count
=
$this
->
dbh
->
count
();
$count
=
$this
->
dbh
->
count
();
...
@@ -345,7 +412,8 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
...
@@ -345,7 +412,8 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
//$this->assertEqual($users[0]->Group[2]->name, "Terminators");
//$this->assertEqual($users[0]->Group[2]->name, "Terminators");
//$this->assertEqual(count($users[0]->Group), 3);
//$this->assertEqual(count($users[0]->Group), 3);
$this
->
clearCache
();
$this
->
session
->
getTable
(
"User"
)
->
clear
();
$this
->
session
->
getTable
(
"Phonenumber"
)
->
clear
();
$users
=
$query
->
query
(
"FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'"
);
$users
=
$query
->
query
(
"FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'"
);
$this
->
assertEqual
(
trim
(
$query
->
getQuery
()),
$this
->
assertEqual
(
trim
(
$query
->
getQuery
()),
...
@@ -449,6 +517,5 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
...
@@ -449,6 +517,5 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
//$this->assertTrue(isset($values['max']));
//$this->assertTrue(isset($values['max']));
}
}
}
}
?>
?>
tests/run.php
View file @
95434d72
...
@@ -23,7 +23,7 @@ error_reporting(E_ALL);
...
@@ -23,7 +23,7 @@ error_reporting(E_ALL);
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
//$test->addTestCase(new Sensei_UnitTestCase());
//$test->addTestCase(new Sensei_UnitTestCase());
/**
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
...
@@ -45,7 +45,7 @@ $test->addTestCase(new Doctrine_ConfigurableTestCase());
...
@@ -45,7 +45,7 @@ $test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Doctrine_Collection_OffsetTestCase());
$test->addTestCase(new Doctrine_Collection_OffsetTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase());
*/
$test
->
addTestCase
(
new
Doctrine_QueryTestCase
());
$test
->
addTestCase
(
new
Doctrine_QueryTestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
...
...
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