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
44809328
Commit
44809328
authored
May 15, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
fb29ca0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
16 deletions
+68
-16
Hydrate.php
draft/new-core/Hydrate.php
+8
-0
Query.php
draft/new-core/Query.php
+60
-16
No files found.
draft/new-core/Hydrate.php
View file @
44809328
...
...
@@ -162,6 +162,14 @@ class Doctrine_Hydrate2
}
$this
->
parts
[
$name
][]
=
$part
;
}
public
function
getDeclaration
(
$name
)
{
if
(
!
isset
(
$this
->
_aliasMap
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown component alias '
.
$name
);
}
return
$this
->
_aliasMap
[
$name
];
}
public
function
setQueryPart
(
$name
,
$part
)
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
...
...
draft/new-core/Query.php
View file @
44809328
...
...
@@ -454,7 +454,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
if
(
!
empty
(
$e2
))
{
$parser
=
new
Doctrine_Query_JoinCondition
(
$this
);
$part
.=
' AND '
.
$parser
->
parse
(
implode
(
' AND '
,
$e2
));
$part
.=
' AND '
.
$parser
->
_
parse
(
implode
(
' AND '
,
$e2
));
}
$q
.=
' '
.
$part
;
...
...
@@ -949,42 +949,61 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
}
/**
* count
* fetches the count of the query
*
* This method executes the main query without all the
* selected fields, ORDER BY part, LIMIT part and OFFSET part.
*
* @param array $params
* @return integer
* Example:
* Main query:
* SELECT u.*, p.phonenumber FROM User u
* LEFT JOIN u.Phonenumber p
* WHERE p.phonenumber = '123 123' LIMIT 10
*
* The query this method executes:
* SELECT COUNT(DISTINCT u.id) FROM User u
* LEFT JOIN u.Phonenumber p
* WHERE p.phonenumber = '123 123'
*
* @param array $params an array of prepared statement parameters
* @return integer the count of this query
*/
public
function
count
(
$params
=
array
())
{
$oldParts
=
$this
->
parts
;
$join
=
$this
->
join
;
$where
=
$this
->
where
;
$having
=
$this
->
having
;
$table
=
reset
(
$this
->
tables
);
// initialize temporary variables
$where
=
$this
->
parts
[
'where'
];
$having
=
$this
->
parts
[
'having'
];
$map
=
reset
(
$this
->
_aliasMap
);
$componentAlias
=
key
(
$this
->
_aliasMap
);
$table
=
$map
[
'table'
];
// build the query base
$q
=
'SELECT COUNT(DISTINCT '
.
$this
->
aliasHandler
->
getShortAlias
(
$table
->
getTableName
())
.
'.'
.
$table
->
getIdentifier
()
.
') FROM '
.
$t
able
->
getTableName
()
.
' '
.
$this
->
aliasHandler
->
getShortAlias
(
$table
->
getTableName
()
);
.
') FROM '
.
$t
his
->
buildFromPart
(
);
foreach
(
$join
as
$j
)
{
$q
.=
' '
.
implode
(
' '
,
$j
);
}
// append column aggregation inheritance (if needed)
$string
=
$this
->
applyInheritance
();
if
(
!
empty
(
$string
))
{
$where
[]
=
$string
;
}
// append conditions
$q
.=
(
!
empty
(
$where
))
?
' WHERE '
.
implode
(
' AND '
,
$where
)
:
''
;
$q
.=
(
!
empty
(
$having
))
?
' HAVING '
.
implode
(
' AND '
,
$having
)
:
''
;
if
(
!
is_array
(
$params
))
{
if
(
!
is_array
(
$params
))
{
$params
=
array
(
$params
);
}
// append parameters
$params
=
array_merge
(
$this
->
params
,
$params
);
return
(
int
)
$this
->
getConnection
()
->
fetchOne
(
$q
,
$params
);
}
/**
* isLimitSubqueryUsed
* whether or not limit subquery algorithm is used
*
* @return boolean
*/
public
function
isLimitSubqueryUsed
()
{
...
...
@@ -1100,6 +1119,31 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
{
return
$this
->
getParser
(
'select'
)
->
parse
(
$select
);
}
/**
* delete
* sets the query type to DELETE
*
* @return Doctrine_Query
*/
public
function
delete
()
{
$this
->
type
=
self
::
DELETE
;
return
$this
;
}
/**
* update
* sets the UPDATE part of the query
*
* @param string $update DQL UPDATE part
* @return Doctrine_Query
*/
public
function
update
(
$update
)
{
$this
->
type
=
self
::
UPDATE
;
return
$this
->
getParser
(
'from'
)
->
parse
(
$update
);
}
/**
* from
* sets the FROM part of the query
...
...
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