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
d899509c
Commit
d899509c
authored
Jul 30, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor bug fix
parent
7a020a52
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
14 deletions
+50
-14
Collection.php
Doctrine/Collection.php
+5
-1
Query.php
Doctrine/Query.php
+32
-2
Record.php
Doctrine/Record.php
+13
-11
No files found.
Doctrine/Collection.php
View file @
d899509c
...
@@ -491,6 +491,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -491,6 +491,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param string $name
* @param string $name
*/
*/
public
function
loadRelated
(
$name
)
{
public
function
loadRelated
(
$name
)
{
$rel
=
$this
->
table
->
getForeignKey
(
$name
);
$rel
=
$this
->
table
->
getForeignKey
(
$name
);
$table
=
$rel
->
getTable
();
$table
=
$rel
->
getTable
();
$query
=
new
Doctrine_Query
(
$this
->
table
->
getSession
());
$query
=
new
Doctrine_Query
(
$this
->
table
->
getSession
());
...
@@ -528,10 +529,13 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -528,10 +529,13 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
" WHERE "
.
$local
.
" WHERE "
.
$local
.
" IN "
.
$paramStr
;
" IN "
.
$paramStr
;
$table
->
getForeignKey
(
$table
->
getAlias
(
$this
->
table
->
getComponentName
()));
$dql
=
"FROM "
.
$table
->
getComponentName
()
.
":"
.
$asf
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$table
->
getIdentifier
()
.
" IN (
$sub
)"
;
$dql
=
"FROM "
.
$table
->
getComponentName
()
.
":"
.
$asf
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$table
->
getIdentifier
()
.
" IN (
$sub
)"
;
//$query->parseQuery($dql);
//$query->parseQuery($dql);
//print Doctrine_Lib::formatSql($query->getQuery());
//print Doctrine_Lib::formatSql($query->getQuery());
}
}
$coll
=
$query
->
query
(
$dql
,
$list
);
$coll
=
$query
->
query
(
$dql
,
$list
);
...
...
Doctrine/Query.php
View file @
d899509c
...
@@ -27,7 +27,38 @@ require_once("Access.php");
...
@@ -27,7 +27,38 @@ require_once("Access.php");
* @license LGPL
* @license LGPL
*/
*/
class
Doctrine_Query
extends
Doctrine_Hydrate
{
class
Doctrine_Query
extends
Doctrine_Hydrate
{
/**
* count
*
* @return integer
*/
public
function
count
(
Doctrine_Table
$table
,
$params
=
array
())
{
$this
->
remove
(
'select'
);
$join
=
$this
->
join
;
$where
=
$this
->
where
;
$having
=
$this
->
having
;
$q
=
"SELECT COUNT(1) FROM "
.
$table
.
" "
;
foreach
(
$join
as
$j
)
{
$q
.=
implode
(
" "
,
$j
);
}
$string
=
$query
->
applyInheritance
();
if
(
!
empty
(
$where
))
{
$q
.=
" WHERE "
.
implode
(
" AND "
,
$where
);
if
(
!
empty
(
$string
))
$q
.=
" AND ("
.
$string
.
")"
;
}
else
{
if
(
!
empty
(
$string
))
$q
.=
" WHERE ("
.
$string
.
")"
;
}
if
(
!
empty
(
$having
))
$q
.=
" HAVING "
.
implode
(
' AND '
,
$having
);
$a
=
$this
->
table
->
getSession
()
->
execute
(
$q
,
$params
)
->
fetch
(
PDO
::
FETCH_NUM
);
return
$a
[
0
];
}
/**
/**
* loadFields
* loadFields
* loads fields for a given table and
* loads fields for a given table and
...
@@ -230,7 +261,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
...
@@ -230,7 +261,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
$string
=
$this
->
applyInheritance
();
$string
=
$this
->
applyInheritance
();
if
(
!
empty
(
$this
->
parts
[
"where"
]))
{
if
(
!
empty
(
$this
->
parts
[
"where"
]))
{
$q
.=
" WHERE "
.
implode
(
" "
,
$this
->
parts
[
"where"
]);
$q
.=
" WHERE "
.
implode
(
"
AND
"
,
$this
->
parts
[
"where"
]);
if
(
!
empty
(
$string
))
if
(
!
empty
(
$string
))
$q
.=
" AND ("
.
$string
.
")"
;
$q
.=
" AND ("
.
$string
.
")"
;
}
else
{
}
else
{
...
@@ -601,5 +632,4 @@ class Doctrine_Query extends Doctrine_Hydrate {
...
@@ -601,5 +632,4 @@ class Doctrine_Query extends Doctrine_Hydrate {
$this
->
loadFields
(
$table
,
$fetchmode
,
$fields
,
$currPath
);
$this
->
loadFields
(
$table
,
$fetchmode
,
$fields
,
$currPath
);
}
}
}
}
?>
?>
Doctrine/Record.php
View file @
d899509c
...
@@ -260,16 +260,22 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -260,16 +260,22 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$type
=
$this
->
table
->
getTypeOf
(
$name
);
$type
=
$this
->
table
->
getTypeOf
(
$name
);
if
(
!
isset
(
$tmp
[
$name
]))
{
if
(
!
isset
(
$tmp
[
$name
]))
{
if
(
$type
==
'array'
)
{
//
if($type == 'array') {
$this
->
data
[
$name
]
=
array
();
//
$this->data[$name] = array();
}
else
//
} else
$this
->
data
[
$name
]
=
self
::
$null
;
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
}
else
{
switch
(
$type
)
:
switch
(
$type
)
:
case
"array"
:
case
"array"
:
case
"object"
:
case
"object"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
$this
->
data
[
$name
]
=
unserialize
(
$tmp
[
$name
]);
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Exception
(
"Unserialization of
$name
failed. "
.
var_dump
(
$tmp
[
$name
],
true
));
print_r
(
$value
);
$this
->
data
[
$name
]
=
$value
;
}
break
;
break
;
case
"enum"
:
case
"enum"
:
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
...
@@ -280,6 +286,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -280,6 +286,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$count
++
;
$count
++
;
}
}
}
}
return
$count
;
return
$count
;
}
}
/**
/**
...
@@ -476,7 +483,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -476,7 +483,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
* @return void
*/
*/
final
public
function
factoryRefresh
()
{
final
public
function
factoryRefresh
()
{
$data
=
$this
->
table
->
getData
();
$
this
->
data
=
$this
->
table
->
getData
();
$old
=
$this
->
id
;
$old
=
$this
->
id
;
$this
->
cleanData
();
$this
->
cleanData
();
...
@@ -486,8 +493,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -486,8 +493,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$this
->
id
!=
$old
)
if
(
$this
->
id
!=
$old
)
throw
new
Doctrine_Record_Exception
();
throw
new
Doctrine_Record_Exception
();
$this
->
data
=
$data
;
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
modified
=
array
();
$this
->
modified
=
array
();
...
@@ -637,9 +642,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -637,9 +642,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
* @return void
*/
*/
public
function
set
(
$name
,
$value
)
{
public
function
set
(
$name
,
$value
)
{
if
(
is_array
(
$value
))
throw
new
Exception
(
$value
);
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
$value
instanceof
Doctrine_Record
)
{
if
(
$value
instanceof
Doctrine_Record
)
{
...
...
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