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
f5e54ad7
Commit
f5e54ad7
authored
Aug 15, 2006
by
pookey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doctrine_Session_Mssql::modifyLimitQuery() added
parent
46965043
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
2 deletions
+80
-2
Common.php
Doctrine/Session/Common.php
+7
-0
Mssql.php
Doctrine/Session/Mssql.php
+54
-0
Oracle.php
Doctrine/Session/Oracle.php
+7
-0
NestedSet.php
Doctrine/Tree/NestedSet.php
+12
-2
No files found.
Doctrine/Session/Common.php
View file @
f5e54ad7
...
...
@@ -3,6 +3,13 @@
* standard session, the parent of pgsql, mysql and sqlite
*/
class
Doctrine_Session_Common
extends
Doctrine_Session
{
/**
* Adds an driver-specific LIMIT clause to the query
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
*/
public
function
modifyLimitQuery
(
$query
,
$limit
=
false
,
$offset
=
false
)
{
if
(
$limit
&&
$offset
)
{
$query
.=
" LIMIT "
.
$limit
.
" OFFSET "
.
$offset
;
...
...
Doctrine/Session/Mssql.php
View file @
f5e54ad7
...
...
@@ -14,5 +14,59 @@ class Doctrine_Session_Mssql extends Doctrine_Session {
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
return
$data
[
0
];
}
/**
* Adds an adapter-specific LIMIT clause to the SELECT statement.
* [ borrowed from Zend Framework ]
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
* @return string
*/
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
if
(
$limit
)
{
// we need the starting SELECT clause for later
$select
=
'SELECT '
;
if
(
preg_match
(
'/^[[:space:]*SELECT[[:space:]]*DISTINCT/i'
,
$query
,
$matches
)
==
1
)
$select
.=
'DISTINCT '
;
$length
=
strlen
(
$select
);
// is there an offset?
if
(
!
$offset
)
{
// no offset, it's a simple TOP count
return
"
$select
TOP
$count
"
.
substr
(
$query
,
$length
);
}
// the total of the count **and** the offset, combined.
// this will be used in the "internal" portion of the
// hacked-up statement.
$total
=
$count
+
$offset
;
// build the "real" order for the external portion.
$order
=
implode
(
','
,
$parts
[
'order'
]);
// build a "reverse" order for the internal portion.
$reverse
=
$order
;
$reverse
=
str_ireplace
(
" ASC"
,
"
\xFF
"
,
$reverse
);
$reverse
=
str_ireplace
(
" DESC"
,
" ASC"
,
$reverse
);
$reverse
=
str_ireplace
(
"
\xFF
"
,
" DESC"
,
$reverse
);
// create a main statement that replaces the SELECT
// with a SELECT TOP
$main
=
"
\n
$select
TOP
$total
"
.
substr
(
$query
,
$length
)
.
"
\n
"
;
// build the hacked-up statement.
// do we really need the "as" aliases here?
$query
=
"SELECT * FROM ("
.
"SELECT TOP
$count
* FROM (
$main
) AS select_limit_rev ORDER BY
$reverse
"
.
") AS select_limit ORDER BY
$order
"
;
}
return
$query
;
}
}
?>
Doctrine/Session/Oracle.php
View file @
f5e54ad7
...
...
@@ -3,6 +3,13 @@
* oracle driver
*/
class
Doctrine_Session_Oracle
extends
Doctrine_Session
{
/**
* Adds an driver-specific LIMIT clause to the query
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
*/
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
$e
=
explode
(
"select "
,
strtolower
(
$query
));
$e2
=
explode
(
" from "
,
$e
[
1
]);
...
...
Doctrine/Tree/NestedSet.php
View file @
f5e54ad7
...
...
@@ -30,11 +30,21 @@
*/
class
Doctrine_Tree_NestedSet
extends
Doctrine_Record
{
public
function
getLeafNodes
()
{
}
public
function
getLeafNodes
()
{
$query
=
"SELECT "
.
implode
(
", "
,
$this
->
table
->
getColumnNames
())
.
" FROM "
.
$this
->
table
->
getTableName
()
.
" WHERE rgt = lft + 1"
;
}
public
function
getPath
()
{
}
public
function
getDepth
()
{
}
public
function
getDepth
()
{
$query
=
"SELECT (COUNT(parent.name) - 1) AS depth
FROM "
.
$this
->
table
->
getTableName
()
.
" AS node,"
.
$this
->
table
->
getTableName
()
.
" AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name"
;
}
public
function
removeNode
()
{
}
...
...
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