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
4289bdd9
Commit
4289bdd9
authored
May 15, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new model now supports DQL DELETEs and UPDATEs
parent
44809328
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
27 deletions
+44
-27
Hydrate.php
draft/new-core/Hydrate.php
+18
-12
Query.php
draft/new-core/Query.php
+11
-0
DeleteTestCase.php
tests/Query/DeleteTestCase.php
+10
-10
UpdateTestCase.php
tests/Query/UpdateTestCase.php
+5
-5
No files found.
draft/new-core/Hydrate.php
View file @
4289bdd9
...
...
@@ -162,7 +162,7 @@ class Doctrine_Hydrate2
}
$this
->
parts
[
$name
][]
=
$part
;
}
public
function
getDeclaration
(
$name
)
public
function
getDeclaration
(
$name
)
{
if
(
!
isset
(
$this
->
_aliasMap
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown component alias '
.
$name
);
...
...
@@ -174,8 +174,13 @@ class Doctrine_Hydrate2
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown query part '
.
$name
);
}
if
(
$name
!==
'limit'
&&
$name
!==
'offset'
)
{
$this
->
parts
[
$name
]
=
array
(
$part
);
}
else
{
$this
->
parts
[
$name
]
=
$part
;
}
$this
->
parts
[
$name
]
=
array
(
$part
);
}
/**
* copyAliases
...
...
@@ -249,16 +254,17 @@ class Doctrine_Hydrate2
{
$this
->
tables
=
array
();
$this
->
parts
=
array
(
"select"
=>
array
(),
"from"
=>
array
(),
"join"
=>
array
(),
"where"
=>
array
(),
"groupby"
=>
array
(),
"having"
=>
array
(),
"orderby"
=>
array
(),
"limit"
=>
false
,
"offset"
=>
false
,
);
'select'
=>
array
(),
'from'
=>
array
(),
'set'
=>
array
(),
'join'
=>
array
(),
'where'
=>
array
(),
'groupby'
=>
array
(),
'having'
=>
array
(),
'orderby'
=>
array
(),
'limit'
=>
false
,
'offset'
=>
false
,
);
$this
->
inheritanceApplied
=
false
;
$this
->
tableAliases
=
array
();
$this
->
aliasHandler
->
clear
();
...
...
draft/new-core/Query.php
View file @
4289bdd9
...
...
@@ -1144,6 +1144,17 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
return
$this
->
getParser
(
'from'
)
->
parse
(
$update
);
}
/**
* set
* sets the SET part of the query
*
* @param string $update DQL UPDATE part
* @return Doctrine_Query
*/
public
function
set
(
$key
,
$value
)
{
return
$this
->
getParser
(
'set'
)
->
parse
(
$key
.
' = '
.
$value
);
}
/**
* from
* sets the FROM part of the query
...
...
tests/Query/DeleteTestCase.php
View file @
4289bdd9
...
...
@@ -35,13 +35,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
{
public
function
testDeleteAllWithColumnAggregationInheritance
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
'DELETE FROM User'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
'DELETE FROM entity WHERE (type = 0)'
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
delete
()
->
from
(
'User'
);
...
...
@@ -49,13 +49,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
}
public
function
testDeleteAll
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
'DELETE FROM Entity'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
'DELETE FROM entity'
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
delete
()
->
from
(
'Entity'
);
...
...
@@ -63,13 +63,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
}
public
function
testDeleteWithCondition
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
'DELETE FROM Entity WHERE id = 3'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
'DELETE FROM entity WHERE id = 3'
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
delete
()
->
from
(
'Entity'
)
->
where
(
'id = 3'
);
...
...
@@ -77,13 +77,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
}
public
function
testDeleteWithLimit
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
'DELETE FROM Entity LIMIT 20'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
'DELETE FROM entity LIMIT 20'
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
delete
()
->
from
(
'Entity'
)
->
limit
(
20
);
...
...
@@ -91,13 +91,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
}
public
function
testDeleteWithLimitAndOffset
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
'DELETE FROM Entity LIMIT 10 OFFSET 20'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
'DELETE FROM entity LIMIT 10 OFFSET 20'
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
delete
()
->
from
(
'Entity'
)
->
limit
(
10
)
->
offset
(
20
);
...
...
tests/Query/UpdateTestCase.php
View file @
4289bdd9
...
...
@@ -35,13 +35,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
{
public
function
testUpdateAllWithColumnAggregationInheritance
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
"UPDATE User u SET u.name = 'someone'"
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"UPDATE entity SET name = 'someone' WHERE (type = 0)"
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
update
(
'User u'
)
->
set
(
'u.name'
,
"'someone'"
);
...
...
@@ -49,13 +49,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
}
public
function
testUpdateWorksWithMultipleColumns
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
"UPDATE User u SET u.name = 'someone', u.email_id = 5"
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"UPDATE entity SET name = 'someone', email_id = 5 WHERE (type = 0)"
);
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
update
(
'User u'
)
->
set
(
'u.name'
,
"'someone'"
)
->
set
(
'u.email_id'
,
5
);
...
...
@@ -63,7 +63,7 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
}
public
function
testUpdateSupportsConditions
()
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
2
();
$q
->
parseQuery
(
"UPDATE User u SET u.name = 'someone' WHERE u.id = 5"
);
...
...
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