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
53bdc31a
Commit
53bdc31a
authored
Oct 26, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added adapter skeletons, fixed wrong limit subquery ordering
parent
b014566e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
11 deletions
+133
-11
Interface.php
lib/Doctrine/Adapter/Interface.php
+39
-0
Statement.php
lib/Doctrine/Adapter/Statement.php
+47
-0
Hydrate.php
lib/Doctrine/Hydrate.php
+4
-3
Query.php
lib/Doctrine/Query.php
+6
-4
PgsqlTestCase.php
tests/DataDict/PgsqlTestCase.php
+30
-0
SqliteTestCase.php
tests/DataDict/SqliteTestCase.php
+3
-0
run.php
tests/run.php
+4
-4
No files found.
lib/Doctrine/Adapter/Interface.php
0 → 100644
View file @
53bdc31a
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Adapter_Interface
*
* @author Konsta Vesterinen
* @license LGPL
* @package Doctrine
*/
interface
Doctrine_Adapter_Interface
{
public
function
prepare
(
$prepareString
);
public
function
query
(
$queryString
);
public
function
quote
(
$input
);
public
function
exec
(
$statement
);
public
function
lastInsertId
();
public
function
beginTransaction
();
public
function
commit
();
public
function
rollBack
();
public
function
errorCode
();
public
function
errorInfo
();
}
lib/Doctrine/Adapter/Statement.php
0 → 100644
View file @
53bdc31a
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Adapter_Statement
*
* @author Konsta Vesterinen
* @license LGPL
* @package Doctrine
*/
abstract
class
Doctrine_Adapter_Statement
{
public
function
bindValue
(
$no
,
$value
)
{
}
public
function
fetch
()
{
}
public
function
nextRowset
()
{
}
public
function
execute
()
{
}
public
function
errorCode
()
{
}
public
function
errorInfo
()
{
}
public
function
rowCount
()
{
}
public
function
setFetchMode
(
$mode
)
{
}
public
function
columnCount
(){
}
}
lib/Doctrine/Hydrate.php
View file @
53bdc31a
...
...
@@ -329,14 +329,15 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
array_walk
(
$params
,
array
(
__CLASS__
,
'convertBoolean'
));
if
(
!
$this
->
view
)
$query
=
$this
->
getQuery
();
$query
=
$this
->
getQuery
(
true
);
else
$query
=
$this
->
view
->
getSelectSql
();
if
(
$this
->
isLimitSubqueryUsed
())
if
(
$this
->
isLimitSubqueryUsed
()
&&
$this
->
connection
->
getDBH
()
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
)
!==
'mysql'
)
$params
=
array_merge
(
$params
,
$params
);
$stmt
=
$this
->
connection
->
execute
(
$query
,
$params
);
$stmt
=
$this
->
connection
->
execute
(
$query
,
$params
);
if
(
$this
->
aggregate
)
return
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
...
...
lib/Doctrine/Query.php
View file @
53bdc31a
...
...
@@ -438,7 +438,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
*
* @return string
*/
public
function
getQuery
()
{
public
function
getQuery
(
$executeSubquery
=
false
)
{
if
(
empty
(
$this
->
parts
[
"select"
])
||
empty
(
$this
->
parts
[
"from"
]))
return
false
;
...
...
@@ -488,8 +488,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$dbh
=
$this
->
connection
->
getDBH
();
// mysql doesn't support LIMIT in subqueries
if
(
$dbh
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
)
==
'mysql'
)
{
}
//$dbh->query();
if
(
$dbh
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
)
==
'mysql'
)
{
$list
=
$dbh
->
query
(
$subquery
)
->
fetchAll
(
PDO
::
FETCH_NUM
);
}
$field
=
$table
->
getTableName
()
.
'.'
.
$table
->
getIdentifier
();
array_unshift
(
$this
->
parts
[
'where'
],
$field
.
' IN ('
.
$subquery
.
')'
);
...
...
@@ -548,7 +549,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$subquery
.=
(
!
empty
(
$this
->
parts
[
'where'
]))
?
' WHERE '
.
implode
(
' AND '
,
$this
->
parts
[
'where'
])
:
''
;
$subquery
.=
(
!
empty
(
$this
->
parts
[
'groupby'
]))
?
' GROUP BY '
.
implode
(
', '
,
$this
->
parts
[
'groupby'
])
:
''
;
$subquery
.=
(
!
empty
(
$this
->
parts
[
'having'
]))
?
' HAVING '
.
implode
(
' '
,
$this
->
parts
[
'having'
])
:
''
;
$subquery
.=
(
!
empty
(
$this
->
parts
[
'orderby'
]))
?
' ORDER BY '
.
implode
(
' '
,
$this
->
parts
[
'orderby'
])
:
''
;
// add driver specific limit clause
$subquery
=
$this
->
connection
->
modifyLimitQuery
(
$subquery
,
$this
->
parts
[
'limit'
],
$this
->
parts
[
'offset'
]);
...
...
tests/DataDict/PgsqlTestCase.php
0 → 100644
View file @
53bdc31a
<?php
class
Doctrine_DataDict_Pgsql_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
}
public
function
prepareData
()
{
}
public
function
getDeclaration
(
$type
)
{
return
$this
->
dict
->
getDoctrineDeclaration
(
array
(
'type'
=>
$type
,
'name'
=>
'colname'
,
'length'
=>
2
,
'fixed'
=>
true
));
}
public
function
testGetDoctrineDefinition
()
{
$this
->
dict
=
new
Doctrine_DataDict_Pgsql
();
$this
->
assertEqual
(
$this
->
getDeclaration
(
'smallint'
),
array
(
array
(
'integer'
,
'boolean'
),
2
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'int2'
),
array
(
array
(
'integer'
,
'boolean'
),
2
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'int'
),
array
(
array
(
'integer'
),
4
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'int4'
),
array
(
array
(
'integer'
),
4
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'integer'
),
array
(
array
(
'integer'
),
4
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'serial'
),
array
(
array
(
'integer'
),
4
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'serial4'
),
array
(
array
(
'integer'
),
4
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'bigint'
),
array
(
array
(
'integer'
),
8
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'int8'
),
array
(
array
(
'integer'
),
8
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'bigserial'
),
array
(
array
(
'integer'
),
8
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'serial8'
),
array
(
array
(
'integer'
),
8
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'bool'
),
array
(
array
(
'boolean'
),
1
,
false
,
null
));
$this
->
assertEqual
(
$this
->
getDeclaration
(
'boolean'
),
array
(
array
(
'boolean'
),
1
,
false
,
null
));
}
}
tests/DataDict/SqliteTestCase.php
0 → 100644
View file @
53bdc31a
<?php
?>
tests/run.php
View file @
53bdc31a
...
...
@@ -63,7 +63,7 @@ error_reporting(E_ALL);
print
'<pre>'
;
$test
=
new
GroupTest
(
'Doctrine Framework Unit Tests'
);
/**
$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase());
...
...
@@ -129,8 +129,6 @@ $test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
$test->addTestCase(new Doctrine_BooleanTestCase());
$test->addTestCase(new Doctrine_Record_Filter_TestCase());
$test
->
addTestCase
(
new
Doctrine_Query_Limit_TestCase
());
$test->addTestCase(new Doctrine_Query_Condition_TestCase());
...
...
@@ -149,7 +147,9 @@ $test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
*/
$test
->
addTestCase
(
new
Doctrine_Query_Limit_TestCase
());
$test
->
addTestCase
(
new
Doctrine_EnumTestCase
());
...
...
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