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
9f93dbf1
Commit
9f93dbf1
authored
May 14, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new DQL core now supports FROM and SELECT parts
parent
fa2da84b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
40 deletions
+52
-40
Hydrate.php
draft/new-core/Hydrate.php
+5
-16
Query.php
draft/new-core/Query.php
+47
-24
No files found.
draft/new-core/Hydrate.php
View file @
9f93dbf1
...
...
@@ -364,6 +364,7 @@ class Doctrine_Hydrate2
throw
new
Doctrine_Hydrate_Exception
(
"Couldn't execute query. Component alias map was empty."
);
}
// initialize some variables used within the main loop
reset
(
$this
->
_aliasMap
);
$rootMap
=
current
(
$this
->
_aliasMap
);
$rootAlias
=
key
(
$this
->
_aliasMap
);
$coll
=
new
Doctrine_Collection2
(
$rootMap
[
'table'
]);
...
...
@@ -518,12 +519,13 @@ class Doctrine_Hydrate2
// get the inheritance maps
$array
=
array
();
foreach
(
$this
->
tables
as
$alias
=>
$table
)
{
$array
[
$alias
][]
=
$table
->
inheritanceMap
;
foreach
(
$this
->
_aliasMap
as
$componentAlias
=>
$data
)
{
$tableAlias
=
$this
->
getTableAlias
(
$componentAlias
);
$array
[
$tableAlias
][]
=
$data
[
'table'
]
->
inheritanceMap
;
}
// apply inheritance maps
$str
=
""
;
$str
=
''
;
$c
=
array
();
$index
=
0
;
...
...
@@ -594,19 +596,6 @@ class Doctrine_Hydrate2
$stmt
->
closeCursor
();
return
$array
;
}
/**
* returns a Doctrine_Table for given name
*
* @param string $name component name
* @return Doctrine_Table|boolean
*/
public
function
getTable
(
$name
)
{
if
(
isset
(
$this
->
tables
[
$name
]))
{
return
$this
->
tables
[
$name
];
}
return
false
;
}
/**
* @return string returns a string representation of this object
*/
...
...
draft/new-core/Query.php
View file @
9f93dbf1
...
...
@@ -371,7 +371,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
*/
public
function
count
(
$params
=
array
())
{
$
parts_old
=
$this
->
parts
;
$
oldParts
=
$this
->
parts
;
$this
->
remove
(
'select'
);
$join
=
$this
->
join
;
...
...
@@ -400,12 +400,13 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
if
(
!
empty
(
$having
))
$q
.=
' HAVING '
.
implode
(
' AND '
,
$having
);
if
(
!
is_array
(
$params
))
if
(
!
is_array
(
$params
))
{
$params
=
array
(
$params
);
}
$params
=
array_merge
(
$this
->
params
,
$params
);
$this
->
parts
=
$
parts_old
;
$this
->
parts
=
$
oldParts
;
return
(
int
)
$this
->
getConnection
()
->
fetchOne
(
$q
,
$params
);
}
/**
...
...
@@ -622,7 +623,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
case
self
::
SELECT
:
$distinct
=
(
$this
->
isDistinct
())
?
'DISTINCT '
:
''
;
$q
=
'SELECT '
.
$distinct
.
implode
(
', '
,
$this
->
parts
[
'select'
])
.
' FROM '
;
$q
=
'SELECT '
.
$distinct
.
implode
(
', '
,
$this
->
parts
[
'select'
])
.
' FROM '
;
break
;
}
return
$q
;
...
...
@@ -662,9 +663,12 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
}
$q
=
$this
->
getQueryBase
();
$q
.=
array_shift
(
$this
->
parts
[
'from'
]);
print
$q
;
foreach
(
$this
->
parts
[
'from'
]
as
$part
)
{
foreach
(
$this
->
parts
[
'from'
]
as
$k
=>
$part
)
{
if
(
$k
===
0
)
{
$q
.=
$part
;
continue
;
}
// preserve LEFT JOINs only if needed
...
...
@@ -1046,12 +1050,12 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
$tmp
=
explode
(
' '
,
$path
);
$componentAlias
=
(
count
(
$tmp
)
>
1
)
?
end
(
$tmp
)
:
false
;
$e
=
preg_split
(
"/[.:]/"
,
$tmp
[
0
],
-
1
);
$fullPath
=
$tmp
[
0
];
$prevPath
=
''
;
$fullLength
=
strlen
(
$fullPath
);
if
(
isset
(
$this
->
_aliasMap
[
$e
[
0
]]))
{
$table
=
$this
->
_aliasMap
[
$e
[
0
]][
'table'
];
...
...
@@ -1059,23 +1063,27 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
}
foreach
(
$e
as
$key
=>
$name
)
{
// get length of the previous path
$length
=
strlen
(
$prevPath
);
// build the current component path
$prevPath
=
(
$prevPath
)
?
$prevPath
.
'.'
.
$name
:
$name
;
$delimeter
=
substr
(
$fullPath
,
$length
,
1
);
// if an alias is not given use the current path as an alias identifier
if
(
$prevPath
!==
$fullPa
th
||
!
$componentAlias
)
{
if
(
strlen
(
$prevPath
)
!==
$fullLeng
th
||
!
$componentAlias
)
{
$componentAlias
=
$prevPath
;
}
// load fields if necessary
if
(
$loadFields
)
{
$this
->
pendingFields
[
$componentAlias
]
=
array
(
'*'
);
}
if
(
!
isset
(
$table
))
{
// process the root of the path
$table
=
$this
->
loadRoot
(
$name
,
$componentAlias
);
}
else
{
$join
=
(
$delimeter
==
':'
)
?
'INNER JOIN '
:
'LEFT JOIN '
;
$relation
=
$table
->
getRelation
(
$name
);
$this
->
_aliasMap
[
$componentAlias
]
=
array
(
'table'
=>
$relation
->
getTable
(),
'parent'
=>
$parent
,
...
...
@@ -1108,7 +1116,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
$assocAlias
=
$this
->
getShortAlias
(
$assocPath
,
$asf
->
getTableName
());
$queryPart
=
'LEFT JOIN '
.
$assocTableName
.
' '
.
$assocAlias
.
' ON '
.
$localAlias
.
'.'
$queryPart
=
$join
.
$assocTableName
.
' '
.
$assocAlias
.
' ON '
.
$localAlias
.
'.'
.
$table
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$relation
->
getLocal
();
...
...
@@ -1119,7 +1127,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
$this
->
parts
[
'from'
][]
=
$queryPart
;
$queryPart
=
'LEFT JOIN '
.
$foreignSql
.
' ON '
.
$foreignAlias
.
'.'
$queryPart
=
$join
.
$foreignSql
.
' ON '
.
$foreignAlias
.
'.'
.
$relation
->
getTable
()
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$relation
->
getForeign
()
.
$joinCondition
;
...
...
@@ -1130,7 +1138,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
}
}
else
{
$queryPart
=
'LEFT JOIN '
.
$local
Sql
$queryPart
=
$join
.
$foreign
Sql
.
' ON '
.
$localAlias
.
'.'
.
$relation
->
getLocal
()
.
' = '
.
$foreignAlias
.
'.'
.
$relation
->
getForeign
()
.
$joinCondition
;
...
...
@@ -1138,9 +1146,24 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable {
$this
->
parts
[
'from'
][]
=
$queryPart
;
}
if
(
$loadFields
)
{
$restoreState
=
false
;
// load fields if necessary
if
(
$loadFields
&&
empty
(
$this
->
pendingFields
))
{
$this
->
pendingFields
[
$componentAlias
]
=
array
(
'*'
);
$restoreState
=
true
;
}
if
(
isset
(
$this
->
pendingFields
[
$componentAlias
]))
{
$this
->
processPendingFields
(
$componentAlias
);
}
if
(
$restoreState
)
{
$this
->
pendingFields
=
array
();
}
if
(
isset
(
$this
->
pendingAggregates
[
$componentAlias
])
||
isset
(
$this
->
pendingAggregates
[
0
]))
{
$this
->
processPendingAggregates
(
$componentAlias
);
}
...
...
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