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
c1280d31
Commit
c1280d31
authored
Oct 18, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refs #175, Removed $collections instance variable from Doctrine_Record
parent
1c8cf027
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
76 deletions
+153
-76
Query.php
lib/Doctrine/Query.php
+36
-10
Orderby.php
lib/Doctrine/Query/Orderby.php
+36
-11
Part.php
lib/Doctrine/Query/Part.php
+44
-8
Set.php
lib/Doctrine/Query/Set.php
+34
-0
Record.php
lib/Doctrine/Record.php
+3
-47
No files found.
lib/Doctrine/Query.php
View file @
c1280d31
...
@@ -27,10 +27,21 @@
...
@@ -27,10 +27,21 @@
* @license LGPL
* @license LGPL
*/
*/
class
Doctrine_Query
extends
Doctrine_Hydrate
implements
Countable
{
class
Doctrine_Query
extends
Doctrine_Hydrate
implements
Countable
{
const
SELECT
=
0
;
/**
* QUERY TYPE CONSTANTS
*/
/**
* constant for SELECT queries
*/
const
SELECT
=
0
;
/**
* constant for DELETE queries
*/
const
DELETE
=
1
;
const
DELETE
=
1
;
/**
* constant for UPDATE queries
*/
const
UPDATE
=
2
;
const
UPDATE
=
2
;
/**
/**
* @param array $subqueryAliases the table aliases needed in some LIMIT subqueries
* @param array $subqueryAliases the table aliases needed in some LIMIT subqueries
...
@@ -52,7 +63,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -52,7 +63,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
private
$isDistinct
=
false
;
private
$isDistinct
=
false
;
private
$pendingFields
=
array
();
private
$pendingFields
=
array
();
/**
* @var integer $type the query type
*
* @see Doctrine_Query::* constants
*/
protected
$type
=
self
::
SELECT
;
protected
$type
=
self
::
SELECT
;
/**
/**
...
@@ -297,7 +312,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -297,7 +312,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
break
;
break
;
case
'update'
:
case
'update'
:
$this
->
type
=
self
::
UPDATE
;
$this
->
type
=
self
::
UPDATE
;
break
;
$name
=
'from'
;
case
'from'
:
case
'from'
:
$this
->
parts
[
'from'
]
=
array
();
$this
->
parts
[
'from'
]
=
array
();
$this
->
parts
[
'select'
]
=
array
();
$this
->
parts
[
'select'
]
=
array
();
...
@@ -359,6 +374,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -359,6 +374,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
* @return boolean
* @return boolean
*/
*/
public
function
set
(
$name
,
$value
)
{
public
function
set
(
$name
,
$value
)
{
/**
if(isset($this->parts[$name])) {
if(isset($this->parts[$name])) {
$method = "parse".ucwords($name);
$method = "parse".ucwords($name);
...
@@ -390,6 +406,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -390,6 +406,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
return true;
return true;
}
}
return false;
return false;
*/
$class
=
new
Doctrine_Query_Set
(
$this
);
$class
->
parse
(
$name
,
$value
);
}
}
/**
/**
* @return boolean
* @return boolean
...
@@ -451,8 +470,10 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -451,8 +470,10 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$q
.=
implode
(
", "
,
$a
);
$q
.=
implode
(
", "
,
$a
);
if
(
$needsSubQuery
)
if
(
$needsSubQuery
)
$subquery
=
'SELECT DISTINCT '
.
$table
->
getTableName
()
.
"."
.
$table
->
getIdentifier
()
.
$subquery
=
'SELECT DISTINCT '
.
$table
->
getTableName
()
' FROM '
.
$table
->
getTableName
();
.
'.'
.
$table
->
getIdentifier
()
.
' FROM '
.
$table
->
getTableName
();
if
(
!
empty
(
$this
->
parts
[
'join'
]))
{
if
(
!
empty
(
$this
->
parts
[
'join'
]))
{
foreach
(
$this
->
parts
[
'join'
]
as
$part
)
{
foreach
(
$this
->
parts
[
'join'
]
as
$part
)
{
...
@@ -570,7 +591,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -570,7 +591,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$part
=
trim
(
$part
);
$part
=
trim
(
$part
);
switch
(
strtolower
(
$part
))
{
switch
(
strtolower
(
$part
))
{
case
'delete'
:
case
'delete'
:
case
'update'
:
case
'select'
:
case
'select'
:
case
'set'
:
case
'from'
:
case
'from'
:
case
'where'
:
case
'where'
:
case
'limit'
:
case
'limit'
:
...
@@ -604,15 +627,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -604,15 +627,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
case
'DELETE'
:
case
'DELETE'
:
$this
->
type
=
self
::
DELETE
;
$this
->
type
=
self
::
DELETE
;
break
;
break
;
case
'UPDATE'
:
$this
->
type
=
self
::
UPDATE
;
break
;
case
'SELECT'
:
case
'SELECT'
:
$this
->
type
=
self
::
SELECT
;
$this
->
type
=
self
::
SELECT
;
$this
->
parseSelect
(
$part
);
$this
->
parseSelect
(
$part
);
break
;
break
;
case
'UPDATE'
:
$this
->
type
=
self
::
UPDATE
;
$k
=
'FROM'
;
case
'FROM'
:
case
'FROM'
:
$class
=
"Doctrine_Query_"
.
ucwords
(
strtolower
(
$k
));
case
'SET'
:
$class
=
'Doctrine_Query_'
.
ucwords
(
strtolower
(
$k
));
$parser
=
new
$class
(
$this
);
$parser
=
new
$class
(
$this
);
$parser
->
parse
(
$part
);
$parser
->
parse
(
$part
);
break
;
break
;
...
...
lib/Doctrine/Query/Orderby.php
View file @
c1280d31
<?php
<?php
require_once
(
"Part.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
::
autoload
(
'Doctrine_Query_Part'
);
/**
* Doctrine_Query_Orderby
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Query_Orderby
extends
Doctrine_Query_Part
{
class
Doctrine_Query_Orderby
extends
Doctrine_Query_Part
{
/**
/**
* DQL ORDER BY PARSER
* DQL ORDER BY PARSER
...
@@ -9,17 +34,17 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part {
...
@@ -9,17 +34,17 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part {
* @param string $str
* @param string $str
* @return void
* @return void
*/
*/
final
public
function
parse
(
$str
)
{
public
function
parse
(
$str
)
{
$ret
=
array
();
$ret
=
array
();
foreach
(
explode
(
","
,
trim
(
$str
))
as
$r
)
{
foreach
(
explode
(
','
,
trim
(
$str
))
as
$r
)
{
$r
=
trim
(
$r
);
$r
=
trim
(
$r
);
$e
=
explode
(
" "
,
$r
);
$e
=
explode
(
' '
,
$r
);
$a
=
explode
(
"."
,
$e
[
0
]);
$a
=
explode
(
'.'
,
$e
[
0
]);
if
(
count
(
$a
)
>
1
)
{
if
(
count
(
$a
)
>
1
)
{
$field
=
array_pop
(
$a
);
$field
=
array_pop
(
$a
);
$reference
=
implode
(
"."
,
$a
);
$reference
=
implode
(
'.'
,
$a
);
$name
=
end
(
$a
);
$name
=
end
(
$a
);
...
@@ -29,18 +54,18 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part {
...
@@ -29,18 +54,18 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part {
$tname
=
$this
->
query
->
getTable
(
$alias
)
->
getTableName
();
$tname
=
$this
->
query
->
getTable
(
$alias
)
->
getTableName
();
$r
=
$alias
.
"."
.
$field
;
$r
=
$alias
.
'.'
.
$field
;
if
(
isset
(
$e
[
1
]))
if
(
isset
(
$e
[
1
]))
$r
.=
" "
.
$e
[
1
];
$r
.=
' '
.
$e
[
1
];
}
}
$ret
[]
=
$r
;
$ret
[]
=
$r
;
}
}
return
implode
(
", "
,
$ret
);
return
implode
(
', '
,
$ret
);
}
}
public
function
__toString
()
{
public
function
__toString
()
{
return
(
!
empty
(
$this
->
parts
))
?
implode
(
", "
,
$this
->
parts
)
:
''
;
return
(
!
empty
(
$this
->
parts
))
?
implode
(
', '
,
$this
->
parts
)
:
''
;
}
}
}
}
lib/Doctrine/Query/Part.php
View file @
c1280d31
<?php
<?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
::
autoload
(
"Doctrine_Access"
);
Doctrine
::
autoload
(
"Doctrine_Access"
);
/**
* Doctrine_Query_Part
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
abstract
class
Doctrine_Query_Part
extends
Doctrine_Access
{
abstract
class
Doctrine_Query_Part
extends
Doctrine_Access
{
/**
* @var Doctrine_Query $query the query object associated with this parser
*/
protected
$query
;
protected
$query
;
/**
* @var string $name the name of this parser
*/
protected
$name
;
protected
$name
;
/**
* @var array $parts
*/
protected
$parts
=
array
();
protected
$parts
=
array
();
/**
* @param Doctrine_Query $query the query object associated with this parser
*/
public
function
__construct
(
Doctrine_Query
$query
)
{
public
function
__construct
(
Doctrine_Query
$query
)
{
$this
->
query
=
$query
;
$this
->
query
=
$query
;
}
}
/**
* @return string $name the name of this parser
*/
public
function
getName
()
{
public
function
getName
()
{
return
$this
->
name
;
return
$this
->
name
;
}
}
/**
* @return Doctrine_Query $query the query object associated with this parser
*/
public
function
getQuery
()
{
public
function
getQuery
()
{
return
$this
->
query
;
return
$this
->
query
;
}
}
...
...
lib/Doctrine/Query/Set.php
0 → 100644
View file @
c1280d31
<?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_Query
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class
Doctrine_Query_Set
extends
Doctrine_Query_Part
{
public
function
parse
(
$dql
)
{
$e
=
Doctrine_Query
::
sqlExplode
(
$dql
,
'='
);
}
}
?>
lib/Doctrine/Record.php
View file @
c1280d31
...
@@ -95,10 +95,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -95,10 +95,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var Doctrine_Validator_ErrorStack error stack object
* @var Doctrine_Validator_ErrorStack error stack object
*/
*/
protected
$_errorStack
;
protected
$_errorStack
;
/**
* @var array $collections the collections this record is in
*/
private
$collections
=
array
();
/**
/**
* @var array $references an array containing all the references
* @var array $references an array containing all the references
*/
*/
...
@@ -494,38 +490,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -494,38 +490,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
}
}
/**
* addCollection
*
* @param Doctrine_Collection $collection
* @param mixed $key
*/
final
public
function
addCollection
(
Doctrine_Collection
$collection
,
$key
=
null
)
{
if
(
$key
!==
null
)
{
$this
->
collections
[
$key
]
=
$collection
;
}
else
{
$this
->
collections
[]
=
$collection
;
}
}
/**
* getCollection
* @param integer $key
* @return Doctrine_Collection
*/
final
public
function
getCollection
(
$key
)
{
return
$this
->
collections
[
$key
];
}
/**
* hasCollections
* whether or not this record is part of a collection
*
* @return boolean
*/
final
public
function
hasCollections
()
{
return
(
!
empty
(
$this
->
collections
));
}
/**
/**
* getState
* getState
* returns the current state of the object
* returns the current state of the object
...
@@ -646,16 +610,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -646,16 +610,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
load
()
{
public
function
load
()
{
// only load the data from database if the Doctrine_Record is in proxy state
// only load the data from database if the Doctrine_Record is in proxy state
if
(
$this
->
_state
==
Doctrine_Record
::
STATE_PROXY
)
{
if
(
$this
->
_state
==
Doctrine_Record
::
STATE_PROXY
)
{
if
(
!
empty
(
$this
->
collections
))
{
// delegate the loading operation to collections in which this record resides
foreach
(
$this
->
collections
as
$collection
)
{
$collection
->
load
(
$this
);
}
}
else
{
$this
->
refresh
();
$this
->
refresh
();
}
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
return
true
;
return
true
;
...
@@ -680,9 +636,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -680,9 +636,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
isset
(
$this
->
_data
[
$lower
]))
{
if
(
isset
(
$this
->
_data
[
$lower
]))
{
// check if the property is null (= it is the Doctrine_Null object located in self::$null)
// check if the property is null (= it is the Doctrine_Null object located in self::$null)
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
{
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
$this
->
load
();
$this
->
load
();
}
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
$value
=
null
;
$value
=
null
;
...
...
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