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
8dc99daa
Commit
8dc99daa
authored
Feb 08, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored many classes
parent
26624104
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
131 deletions
+63
-131
Collection.php
lib/Doctrine/Collection.php
+2
-1
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+2
-2
Expression.php
lib/Doctrine/Expression.php
+1
-1
Hydrate.php
lib/Doctrine/Hydrate.php
+2
-2
Query.php
lib/Doctrine/Query.php
+17
-4
Record.php
lib/Doctrine/Record.php
+2
-2
Self.php
lib/Doctrine/Relation/Association/Self.php
+4
-4
Table.php
lib/Doctrine/Table.php
+33
-115
No files found.
lib/Doctrine/Collection.php
View file @
8dc99daa
...
...
@@ -373,7 +373,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$query
=
"SELECT "
.
$fields
.
" FROM "
.
$this
->
table
->
getTableName
();
// apply column aggregation inheritance
foreach
(
$this
->
table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
$map
=
$this
->
table
->
inheritanceMap
;
foreach
(
$map
as
$k
=>
$v
)
{
$where
[]
=
$k
.
" = ?"
;
$params
[]
=
$v
;
}
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
8dc99daa
...
...
@@ -314,7 +314,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
$table
=
$record
->
getTable
();
$keys
=
$table
->
getPrimaryKeys
();
$seq
=
$record
->
getTable
()
->
getSequenceName
()
;
$seq
=
$record
->
getTable
()
->
sequenceName
;
if
(
!
empty
(
$seq
))
{
$id
=
$this
->
conn
->
sequence
->
nextId
(
$seq
);
...
...
@@ -329,7 +329,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
if
(
empty
(
$seq
)
&&
count
(
$keys
)
==
1
&&
$keys
[
0
]
==
$table
->
getIdentifier
())
{
if
(
strtolower
(
$this
->
conn
->
getName
())
==
'pgsql'
)
{
$seq
=
$table
->
getTableName
()
.
'_'
.
$keys
[
0
];
$seq
=
$table
->
getTableName
()
.
'_'
.
$keys
[
0
];
}
$id
=
$this
->
conn
->
sequence
->
lastInsertId
(
$seq
);
...
...
lib/Doctrine/Expression.php
View file @
8dc99daa
...
...
@@ -269,7 +269,7 @@ class Doctrine_Expression extends Doctrine_Connection_Module
*
* @param string|array(string) strings that will be concatinated.
*/
public
function
concat
(
array
$args
)
public
function
concat
(
$args
)
{
$cols
=
$this
->
getIdentifiers
(
$args
);
return
'CONCAT('
.
join
(
', '
,
$cols
)
.
')'
;
...
...
lib/Doctrine/Hydrate.php
View file @
8dc99daa
...
...
@@ -632,8 +632,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access
$array
=
array
();
foreach
(
$this
->
tables
as
$alias
=>
$table
)
{
$array
[
$alias
][]
=
$table
->
getInheritanceMap
()
;
}
;
$array
[
$alias
][]
=
$table
->
inheritanceMap
;
}
// apply inheritance maps
$str
=
""
;
...
...
lib/Doctrine/Query.php
View file @
8dc99daa
...
...
@@ -1346,17 +1346,20 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$this
->
needsSubquery
=
true
;
}
if
(
!
$loadFields
||
$fk
->
getTable
()
->
usesInheritanceMap
()
||
$joinCondition
)
{
$map
=
$fk
->
getTable
()
->
inheritanceMap
;
if
(
!
$loadFields
||
!
empty
(
$map
)
||
$joinCondition
)
{
$this
->
subqueryAliases
[]
=
$tname2
;
}
if
(
$fk
instanceof
Doctrine_Relation_Association
)
{
if
(
$fk
instanceof
Doctrine_Relation_Association
)
{
$asf
=
$fk
->
getAssociationFactory
();
$assocTableName
=
$asf
->
getTableName
();
if
(
!
$loadFields
||
$fk
->
getTable
()
->
usesInheritanceMap
(
)
||
$joinCondition
)
{
if
(
!
$loadFields
||
!
empty
(
$map
)
||
$joinCondition
)
{
$this
->
subqueryAliases
[]
=
$assocTableName
;
}
...
...
@@ -1368,15 +1371,25 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$assocAlias
=
$this
->
aliasHandler
->
generateShortAlias
(
$assocTableName
);
}
$this
->
parts
[
'join'
][
$tname
][
$assocTableName
]
=
$join
.
$assocTableName
.
' '
.
$assocAlias
.
' ON '
.
$tname
.
'.'
$this
->
parts
[
'join'
][
$tname
][
$assocTableName
]
=
$join
.
$assocTableName
.
' '
.
$assocAlias
.
' ON '
.
$tname
.
'.'
.
$table
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$fk
->
getLocal
();
if
(
$fk
instanceof
Doctrine_Relation_Association_Self
)
{
$this
->
parts
[
'join'
][
$tname
][
$assocTableName
]
.=
' OR '
.
$tname
.
'.'
.
$table
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$fk
->
getForeign
();
}
$this
->
parts
[
'join'
][
$tname
][
$tname2
]
=
$join
.
$aliasString
.
' ON '
.
$tname2
.
'.'
.
$fk
->
getTable
()
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$fk
->
getForeign
()
.
$joinCondition
;
if
(
$fk
instanceof
Doctrine_Relation_Association_Self
)
{
$this
->
parts
[
'join'
][
$tname
][
$tname2
]
.=
' OR '
.
$tname2
.
'.'
.
$table
->
getIdentifier
()
.
' = '
.
$assocAlias
.
'.'
.
$fk
->
getLocal
();
}
}
else
{
$this
->
parts
[
'join'
][
$tname
][
$tname2
]
=
$join
.
$aliasString
.
' ON '
.
$tname
.
'.'
...
...
lib/Doctrine/Record.php
View file @
8dc99daa
...
...
@@ -1068,7 +1068,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
foreach
(
$this
->
_table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
foreach
(
$this
->
_table
->
inheritanceMap
as
$k
=>
$v
)
{
$old
=
$this
->
get
(
$k
,
false
);
if
((
string
)
$old
!==
(
string
)
$v
||
$old
===
null
)
{
...
...
@@ -1477,7 +1477,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
public
function
setTableName
(
$tableName
)
{
$this
->
_table
->
setTableName
(
$tableName
)
;
$this
->
_table
->
tableName
=
$tableName
;
}
public
function
setInheritanceMap
(
$map
)
{
...
...
lib/Doctrine/Relation/Association/Self.php
View file @
8dc99daa
...
...
@@ -51,10 +51,10 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
' WHERE '
.
$this
->
foreign
.
' = ?'
;
$dql
=
'FROM '
.
$this
->
table
->
getComponentName
();
$dql
.=
'.'
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub
.
')'
;
$dql
.=
' || '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub2
.
')'
;
$dql
=
'FROM '
.
$this
->
table
->
getComponentName
();
$dql
.=
'.'
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub
.
')'
;
$dql
.=
' || '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub2
.
')'
;
break
;
case
'collection'
:
$sub
=
substr
(
str_repeat
(
'?, '
,
$count
),
0
,
-
2
);
...
...
lib/Doctrine/Table.php
View file @
8dc99daa
...
...
@@ -109,10 +109,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* determining its state
*/
private
$columnCount
;
/**
* @var array $parents the parent classes of this component
*/
private
$parents
=
array
();
/**
* @var boolean $hasDefaultValues whether or not this table has default values
*/
...
...
@@ -122,6 +118,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* -- name name of the component, for example component name of the GroupTable is 'Group'
*
* -- parents the parent classes of this component
*
* -- declaringClass name of the table definition declaring class (when using inheritance the class
* that defines the table structure can be any class in the inheritance hierarchy,
* hence we need reflection to check out which class actually calls setTableDefinition)
...
...
@@ -308,7 +306,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
// save parents
array_pop
(
$names
);
$this
->
parents
=
$names
;
$this
->
options
[
'parents'
]
=
$names
;
$this
->
query
=
'SELECT '
.
implode
(
', '
,
array_keys
(
$this
->
columns
))
.
' FROM '
.
$this
->
getTableName
();
...
...
@@ -392,6 +390,28 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
throw
$e
;
}
}
/**
* __get
* an alias for getOption
*
* @param string $option
*/
public
function
__get
(
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
return
$this
->
options
[
$option
];
}
return
null
;
}
/**
* __isset
*
* @param string $option
*/
public
function
__isset
(
$option
)
{
return
isset
(
$this
->
options
[
$option
]);
}
/**
* createQuery
* creates a new Doctrine_Query object and adds the component name
...
...
@@ -430,11 +450,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
$this
->
options
[
$name
]
=
$value
;
}
public
function
usesInheritanceMap
()
{
return
(
!
empty
(
$this
->
options
[
'inheritanceMap'
]));
}
public
function
getOption
(
$name
)
{
if
(
isset
(
$this
->
options
[
$name
]))
{
...
...
@@ -592,72 +607,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return
in_array
(
$key
,
$this
->
primaryKeys
);
}
/**
* @param $sequence
* @return void
*/
final
public
function
setSequenceName
(
$sequence
)
{
$this
->
options
[
'sequenceName'
]
=
$sequence
;
}
/**
* @return string sequence name
*/
final
public
function
getSequenceName
()
{
return
$this
->
options
[
'sequenceName'
];
}
/**
* getParents
*/
final
public
function
getParents
()
{
return
$this
->
parents
;
}
/**
* @return boolean
*/
final
public
function
hasInheritanceMap
()
{
return
(
empty
(
$this
->
options
[
'inheritanceMap'
]));
}
/**
* @return array inheritance map (array keys as fields)
*/
final
public
function
getInheritanceMap
()
{
return
$this
->
options
[
'inheritanceMap'
];
}
/**
* return all composite paths in the form [component1].[component2]. . .[componentN]
* @return array
*/
final
public
function
getCompositePaths
()
{
$array
=
array
();
$name
=
$this
->
getComponentName
();
foreach
(
$this
->
bound
as
$k
=>
$a
)
{
try
{
$fk
=
$this
->
getRelation
(
$k
);
switch
(
$fk
->
getType
())
{
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$n
=
$fk
->
getTable
()
->
getComponentName
();
$array
[]
=
$name
.
"."
.
$n
;
$e
=
$fk
->
getTable
()
->
getCompositePaths
();
if
(
!
empty
(
$e
))
{
foreach
(
$e
as
$name
)
{
$array
[]
=
$name
.
"."
.
$n
.
"."
.
$name
;
}
}
break
;
};
}
catch
(
Doctrine_Table_Exception
$e
)
{
}
}
return
$array
;
}
/**
* returns all bound relations
*
...
...
@@ -788,14 +737,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this
->
bound
[
$alias
]
=
array
(
$field
,
$type
,
$localKey
,
$name
);
}
/**
* getComponentName
* @return string the component name
*/
public
function
getComponentName
()
{
return
$this
->
options
[
'name'
];
}
/**
* @return Doctrine_Connection
*/
...
...
@@ -960,26 +901,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return
$this
->
relations
;
}
/**
* sets the database table name
*
* @param string $name database table name
* @return void
*/
final
public
function
setTableName
(
$name
)
{
$this
->
options
[
'tableName'
]
=
$name
;
}
/**
* returns the database table name
*
* @return string
*/
final
public
function
getTableName
()
{
return
$this
->
options
[
'tableName'
];
}
/**
* create
* creates a new record
...
...
@@ -1182,17 +1103,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
return
$coll
;
}
/**
* sets enumerated value array for given field
*
* @param string $field
* @param array $values
* @return void
*/
final
public
function
setEnumValues
(
$field
,
array
$values
)
{
$this
->
options
[
'enumMap'
][
strtolower
(
$field
)]
=
$values
;
}
/**
* @param string $field
* @return array
...
...
@@ -1403,6 +1313,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
return
false
;
}
public
function
getComponentName
()
{
return
$this
->
options
[
'name'
];
}
public
function
getTableName
()
{
return
$this
->
options
[
'tableName'
];
}
/**
* determine if table acts as tree
*
...
...
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