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
3578ca55
Commit
3578ca55
authored
May 15, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
dce54885
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
51 deletions
+53
-51
Collection.php
draft/new-core/Collection.php
+1
-2
Hydrate.php
draft/new-core/Hydrate.php
+29
-17
Query.php
draft/new-core/Query.php
+23
-32
No files found.
draft/new-core/Collection.php
View file @
3578ca55
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
"Doctrine_Access"
);
Doctrine
::
autoload
(
'Doctrine_Access'
);
/**
* Doctrine_Collection
* Collection of Doctrine_Record objects.
...
...
@@ -62,7 +62,6 @@ class Doctrine_Collection2 extends Doctrine_Collection implements Countable, Ite
*/
protected
static
$null
;
protected
$aggregateValues
=
array
();
/**
* constructor
...
...
draft/new-core/Hydrate.php
View file @
3578ca55
...
...
@@ -155,6 +155,20 @@ class Doctrine_Hydrate2
{
return
$this
->
aliasHandler
->
getShortAlias
(
$componentAlias
);
}
public
function
addQueryPart
(
$name
,
$part
)
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown query part '
.
$name
);
}
$this
->
parts
[
$name
][]
=
$part
;
}
public
function
setQueryPart
(
$name
,
$part
)
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown query part '
.
$name
);
}
$this
->
parts
[
$name
]
=
array
(
$part
);
}
/**
* copyAliases
*
...
...
@@ -331,8 +345,9 @@ class Doctrine_Hydrate2
* @param array $row
* @return Doctrine_Record
*/
public
function
mapAggregateValues
(
$record
,
array
$row
)
public
function
mapAggregateValues
(
$record
,
array
$row
,
$alias
)
{
$found
=
false
;
// aggregate values have numeric keys
if
(
isset
(
$row
[
0
]))
{
// map each aggregate value
...
...
@@ -345,9 +360,10 @@ class Doctrine_Hydrate2
$agg
=
$this
->
subqueryAggregates
[
$alias
][
$index
];
}
$record
->
mapValue
(
$agg
,
$value
);
$found
=
true
;
}
}
return
$
recor
d
;
}
return
$
foun
d
;
}
/**
* execute
...
...
@@ -384,11 +400,7 @@ class Doctrine_Hydrate2
if
(
empty
(
$row
))
{
continue
;
}
// check for validity
if
(
!
isset
(
$this
->
tableAliases
[
$tableAlias
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown table alias '
.
$tableAlias
);
}
$alias
=
$this
->
tableAliases
[
$tableAlias
];
$alias
=
$this
->
aliasHandler
->
getComponentAlias
(
$tableAlias
);
$map
=
$this
->
_aliasMap
[
$alias
];
// initialize previous row array if not set
...
...
@@ -398,20 +410,20 @@ class Doctrine_Hydrate2
// don't map duplicate rows
if
(
$prevRow
[
$tableAlias
]
!==
$row
)
{
// set internal data
$map
[
'table'
]
->
setData
(
$row
);
$identifiable
=
$this
->
isIdentifiable
(
$row
,
$map
[
'table'
]
->
getIdentifier
());
// only initialize record if the current data row is identifiable
if
(
$identifiable
)
{
//
initialize a new record
$
record
=
$map
[
'table'
]
->
getRecord
(
);
//
set internal data
$
map
[
'table'
]
->
setData
(
$row
);
}
// initialize a new record
$record
=
$map
[
'table'
]
->
getRecord
();
// map aggregate values (if any)
$this
->
mapAggregateValues
(
$record
,
$row
);
if
(
$this
->
mapAggregateValues
(
$record
,
$row
,
$alias
))
{
$identifiable
=
true
;
}
if
(
$alias
==
$rootAlias
)
{
...
...
@@ -438,7 +450,7 @@ class Doctrine_Hydrate2
// one-to-many relation or many-to-many relation
if
(
!
$prev
[
$parentAlias
]
->
getLast
()
->
hasReference
(
$relation
->
getAlias
()))
{
// initialize a new collection
$prev
[
$alias
]
=
new
Doctrine_Collection2
(
$
parentM
ap
[
'table'
]);
$prev
[
$alias
]
=
new
Doctrine_Collection2
(
$
m
ap
[
'table'
]);
$prev
[
$alias
]
->
setReference
(
$parent
,
$relation
);
}
else
{
// previous entry found from memory
...
...
draft/new-core/Query.php
View file @
3578ca55
...
...
@@ -338,10 +338,9 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
}
public
function
processPendingAggregates
(
$componentAlias
)
{
$tableAlias
=
$this
->
getTableAlias
(
$componentAlias
);
$tableAlias
=
$this
->
getTableAlias
(
$componentAlias
);
reset
(
$this
->
_aliasMap
);
$map
=
current
(
$this
->
tables
);
$map
=
reset
(
$this
->
_aliasMap
);
$root
=
$map
[
'table'
];
$table
=
$this
->
_aliasMap
[
$componentAlias
][
'table'
];
...
...
@@ -373,7 +372,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
$e
[
1
]
=
$table
->
getColumnName
(
$e
[
1
]);
if
(
!
$table
->
hasColumn
(
$e
[
1
]))
{
if
(
!
$table
->
hasColumn
(
$e
[
1
]))
{
throw
new
Doctrine_Query_Exception
(
'Unknown column '
.
$e
[
1
]);
}
...
...
@@ -385,7 +384,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
$sqlAlias
=
$tableAlias
.
'__'
.
count
(
$this
->
aggregateMap
);
if
(
substr
(
$name
,
0
,
1
)
!==
'('
)
{
if
(
substr
(
$name
,
0
,
1
)
!==
'('
)
{
$this
->
parts
[
'select'
][]
=
$name
.
'('
.
$distinct
.
implode
(
', '
,
$arglist
)
.
') AS '
.
$sqlAlias
;
}
else
{
$this
->
parts
[
'select'
][]
=
$name
.
' AS '
.
$sqlAlias
;
...
...
@@ -542,10 +541,10 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
}
}
$q
.=
(
!
empty
(
$this
->
parts
[
'where'
]))
?
' WHERE '
.
implode
(
' AND '
,
$this
->
parts
[
'where'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'groupby'
]))
?
' GROUP BY '
.
implode
(
', '
,
$this
->
parts
[
'groupby'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'having'
]))
?
' HAVING '
.
implode
(
' AND '
,
$this
->
parts
[
'having'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'orderby'
]))
?
' ORDER BY '
.
implode
(
', '
,
$this
->
parts
[
'orderby'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'where'
]))
?
' WHERE '
.
implode
(
' AND '
,
$this
->
parts
[
'where'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'groupby'
]))
?
' GROUP BY '
.
implode
(
', '
,
$this
->
parts
[
'groupby'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'having'
]))
?
' HAVING '
.
implode
(
' AND '
,
$this
->
parts
[
'having'
])
:
''
;
$q
.=
(
!
empty
(
$this
->
parts
[
'orderby'
]))
?
' ORDER BY '
.
implode
(
', '
,
$this
->
parts
[
'orderby'
])
:
''
;
if
(
$modifyLimit
)
{
$q
=
$this
->
conn
->
modifyLimitQuery
(
$q
,
$this
->
parts
[
'limit'
],
$this
->
parts
[
'offset'
]);
...
...
@@ -757,7 +756,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
case
'set'
:
$class
=
'Doctrine_Query_'
.
ucwords
(
strtolower
(
$k
));
$parser
=
new
$class
(
$this
);
$
this
->
parts
[
'set'
][]
=
$
parser
->
parse
(
$part
);
$parser
->
parse
(
$part
);
break
;
case
'group'
:
case
'order'
:
...
...
@@ -768,7 +767,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
$parser
=
new
$class
(
$this
);
$name
=
strtolower
(
$k
);
$
this
->
parts
[
$name
][]
=
$
parser
->
parse
(
$part
);
$parser
->
parse
(
$part
);
break
;
case
'limit'
:
$this
->
parts
[
'limit'
]
=
trim
(
$part
);
...
...
@@ -898,7 +897,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
if
(
$loadFields
&&
empty
(
$this
->
pendingFields
)
&&
empty
(
$this
->
pendingAggregates
)
&&
empty
(
$this
->
pendingSubqueries
))
{
$this
->
pendingFields
[
$componentAlias
]
=
array
(
'*'
);
$restoreState
=
true
;
...
...
@@ -918,6 +917,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
}
}
}
return
end
(
$this
->
_aliasMap
);
}
/**
* loadRoot
...
...
@@ -959,7 +959,6 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
{
$oldParts
=
$this
->
parts
;
$this
->
remove
(
'select'
);
$join
=
$this
->
join
;
$where
=
$this
->
where
;
$having
=
$this
->
having
;
...
...
@@ -973,18 +972,11 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
$q
.=
' '
.
implode
(
' '
,
$j
);
}
$string
=
$this
->
applyInheritance
();
if
(
!
empty
(
$where
))
{
$q
.=
' WHERE '
.
implode
(
' AND '
,
$where
);
if
(
!
empty
(
$string
))
$q
.=
' AND ('
.
$string
.
')'
;
}
else
{
if
(
!
empty
(
$string
))
$q
.=
' WHERE ('
.
$string
.
')'
;
if
(
!
empty
(
$string
))
{
$where
[]
=
$string
;
}
if
(
!
empty
(
$having
))
$q
.=
' HAVING '
.
implode
(
' AND '
,
$having
);
$q
.=
(
!
empty
(
$where
))
?
' WHERE '
.
implode
(
' AND '
,
$where
)
:
''
;
$q
.=
(
!
empty
(
$having
))
?
' HAVING '
.
implode
(
' AND '
,
$having
)
:
''
;
if
(
!
is_array
(
$params
))
{
$params
=
array
(
$params
);
...
...
@@ -992,7 +984,6 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
$params
=
array_merge
(
$this
->
params
,
$params
);
$this
->
parts
=
$oldParts
;
return
(
int
)
$this
->
getConnection
()
->
fetchOne
(
$q
,
$params
);
}
/**
...
...
@@ -1136,7 +1127,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
*/
public
function
leftJoin
(
$join
)
{
return
$this
->
getParser
(
'from'
)
->
parse
(
'LE
R
T JOIN '
.
$join
);
return
$this
->
getParser
(
'from'
)
->
parse
(
'LE
F
T JOIN '
.
$join
);
}
/**
* groupBy
...
...
@@ -1187,12 +1178,12 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
* orderBy
* sets the ORDER BY part of the query
*
* @param string $
group
by DQL ORDER BY part
* @param string $
order
by DQL ORDER BY part
* @return Doctrine_Query
*/
public
function
orderBy
(
$
dql
)
public
function
orderBy
(
$
orderby
)
{
return
$this
->
getParser
(
'orderby'
)
->
parse
(
$
dql
);
return
$this
->
getParser
(
'orderby'
)
->
parse
(
$
orderby
);
}
/**
* limit
...
...
@@ -1203,7 +1194,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
*/
public
function
limit
(
$limit
)
{
return
$this
->
getParser
(
'limit'
)
->
parse
(
$
dql
);
return
$this
->
getParser
(
'limit'
)
->
parse
(
$
limit
);
}
/**
* offset
...
...
@@ -1212,9 +1203,9 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
* @param integer $offset offset to be used for paginating the query
* @return Doctrine_Query
*/
public
function
offset
(
$
dql
)
public
function
offset
(
$
offset
)
{
return
$this
->
getParser
(
'offset'
)
->
parse
(
$
dql
);
return
$this
->
getParser
(
'offset'
)
->
parse
(
$
offset
);
}
}
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