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
ff0aad6b
Commit
ff0aad6b
authored
Apr 15, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit offset support fixed
parent
be1d5f16
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
9 deletions
+48
-9
DB.class.php
classes/DB.class.php
+1
-1
Parser.class.php
classes/DQL/Parser.class.php
+16
-1
Record.class.php
classes/Record.class.php
+1
-1
Common.class.php
classes/Session/Common.class.php
+10
-2
Ip.class.php
classes/Validator/Ip.class.php
+1
-1
DQLParserTestCase.class.php
tests/DQLParserTestCase.class.php
+16
-0
run.php
tests/run.php
+3
-3
No files found.
classes/DB.class.php
View file @
ff0aad6b
...
@@ -65,8 +65,8 @@ class Doctrine_DB extends PDO implements Countable, IteratorAggregate {
...
@@ -65,8 +65,8 @@ class Doctrine_DB extends PDO implements Countable, IteratorAggregate {
public
function
query
(
$query
)
{
public
function
query
(
$query
)
{
$this
->
queries
[]
=
$query
;
$this
->
queries
[]
=
$query
;
$time
=
microtime
();
$time
=
microtime
();
$stmt
=
parent
::
query
(
$query
);
$stmt
=
parent
::
query
(
$query
);
$this
->
exectimes
[]
=
(
microtime
()
-
$time
);
$this
->
exectimes
[]
=
(
microtime
()
-
$time
);
return
$stmt
;
return
$stmt
;
}
}
...
...
classes/DQL/Parser.class.php
View file @
ff0aad6b
...
@@ -128,6 +128,18 @@ class Doctrine_DQL_Parser {
...
@@ -128,6 +128,18 @@ class Doctrine_DQL_Parser {
}
}
}
}
}
}
/**
* @return integer
*/
final
public
function
getLimit
()
{
return
$this
->
limit
;
}
/**
* @return integer
*/
final
public
function
getOffset
()
{
return
$this
->
offset
;
}
/**
/**
* @return string the built sql query
* @return string the built sql query
*/
*/
...
@@ -153,6 +165,9 @@ class Doctrine_DQL_Parser {
...
@@ -153,6 +165,9 @@ class Doctrine_DQL_Parser {
if
(
!
empty
(
$this
->
orderby
))
if
(
!
empty
(
$this
->
orderby
))
$q
.=
" ORDER BY "
.
implode
(
", "
,
$this
->
orderby
);
$q
.=
" ORDER BY "
.
implode
(
", "
,
$this
->
orderby
);
if
(
!
empty
(
$this
->
limit
)
||
!
empty
(
$this
->
offset
))
$q
=
$this
->
session
->
modifyLimitQuery
(
$q
,
$this
->
limit
,
$this
->
offset
);
return
$q
;
return
$q
;
}
}
/**
/**
...
@@ -182,7 +197,7 @@ class Doctrine_DQL_Parser {
...
@@ -182,7 +197,7 @@ class Doctrine_DQL_Parser {
if
(
!
empty
(
$this
->
orderby
))
if
(
!
empty
(
$this
->
orderby
))
$q
.=
" ORDER BY "
.
implode
(
", "
,
$this
->
orderby
);
$q
.=
" ORDER BY "
.
implode
(
", "
,
$this
->
orderby
);
if
(
!
empty
(
$this
->
limit
)
AND
!
empty
(
$this
->
offset
))
if
(
!
empty
(
$this
->
limit
)
&&
!
empty
(
$this
->
offset
))
$q
=
$this
->
session
->
modifyLimitQuery
(
$q
,
$this
->
limit
,
$this
->
offset
);
$q
=
$this
->
session
->
modifyLimitQuery
(
$q
,
$this
->
limit
,
$this
->
offset
);
return
$q
;
return
$q
;
...
...
classes/Record.class.php
View file @
ff0aad6b
...
@@ -732,7 +732,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -732,7 +732,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* returns a copy of this object
* returns a copy of this object
* @return DAO
* @return DAO
*/
*/
final
public
function
copy
()
{
public
function
copy
()
{
return
$this
->
table
->
create
(
$this
->
data
);
return
$this
->
table
->
create
(
$this
->
data
);
}
}
/**
/**
...
...
classes/Session/Common.class.php
View file @
ff0aad6b
...
@@ -3,8 +3,16 @@
...
@@ -3,8 +3,16 @@
* standard session, the parent of pgsql, mysql and sqlite
* standard session, the parent of pgsql, mysql and sqlite
*/
*/
class
Doctrine_Session_Common
extends
Doctrine_Session
{
class
Doctrine_Session_Common
extends
Doctrine_Session
{
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
public
function
modifyLimitQuery
(
$query
,
$limit
=
null
,
$offset
=
null
)
{
return
$query
.
" LIMIT "
.
$limit
.
" OFFSET "
.
$offset
;
if
(
isset
(
$limit
))
$query
.=
" LIMIT "
.
$limit
;
else
$query
.=
" LIMIT 99999999999999"
;
if
(
isset
(
$offset
))
$query
.=
" OFFSET "
.
$offset
;
return
$query
;
}
}
}
}
?>
?>
classes/Validator/Ip.class.php
View file @
ff0aad6b
<?php
<?php
class
Doctrine_Validator_I
P
{
class
Doctrine_Validator_I
p
{
/**
/**
* @param Doctrine_Record $record
* @param Doctrine_Record $record
* @param string $key
* @param string $key
...
...
tests/DQLParserTestCase.class.php
View file @
ff0aad6b
<?php
<?php
require_once
(
"UnitTestCase.class.php"
);
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_DQL_ParserTestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_DQL_ParserTestCase
extends
Doctrine_UnitTestCase
{
public
function
testLimit
()
{
$graph
=
new
Doctrine_DQL_Parser
(
$this
->
session
);
$coll
=
$graph
->
query
(
"FROM User LIMIT 3"
);
$this
->
assertEqual
(
$graph
->
getLimit
(),
3
);
$this
->
assertEqual
(
$coll
->
count
(),
3
);
}
public
function
testOffset
()
{
$graph
=
new
Doctrine_DQL_Parser
(
$this
->
session
);
$coll
=
$graph
->
query
(
"FROM User LIMIT 3 OFFSET 3"
);
$this
->
assertEqual
(
$graph
->
getOffset
(),
3
);
$this
->
assertEqual
(
$coll
->
count
(),
3
);
}
public
function
testPrepared
()
{
public
function
testPrepared
()
{
$coll
=
$this
->
session
->
query
(
"FROM User WHERE User.name = :name"
,
array
(
":name"
=>
"zYne"
));
$coll
=
$this
->
session
->
query
(
"FROM User WHERE User.name = :name"
,
array
(
":name"
=>
"zYne"
));
$this
->
assertEqual
(
$coll
->
count
(),
1
);
$this
->
assertEqual
(
$coll
->
count
(),
1
);
}
}
public
function
testQuery
()
{
public
function
testQuery
()
{
$graph
=
new
Doctrine_DQL_Parser
(
$this
->
session
);
$graph
=
new
Doctrine_DQL_Parser
(
$this
->
session
);
...
@@ -191,5 +206,6 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
...
@@ -191,5 +206,6 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
isset
(
$values
[
'users'
]));
$this
->
assertTrue
(
isset
(
$values
[
'users'
]));
$this
->
assertTrue
(
isset
(
$values
[
'max'
]));
$this
->
assertTrue
(
isset
(
$values
[
'max'
]));
}
}
}
}
?>
?>
tests/run.php
View file @
ff0aad6b
...
@@ -23,7 +23,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
...
@@ -23,7 +23,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
/**
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
...
@@ -36,10 +36,10 @@ $test->addTestCase(new Doctrine_AccessTestCase());
...
@@ -36,10 +36,10 @@ $test->addTestCase(new Doctrine_AccessTestCase());
$test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Doctrine_EventListenerTestCase());
$test->addTestCase(new Doctrine_EventListenerTestCase());
*/
$test
->
addTestCase
(
new
Doctrine_DQL_ParserTestCase
());
$test
->
addTestCase
(
new
Doctrine_DQL_ParserTestCase
());
$test
->
addTestCase
(
new
Doctrine_BatchIteratorTestCase
());
//
$test->addTestCase(new Doctrine_BatchIteratorTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
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