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
c9291743
Commit
c9291743
authored
Aug 31, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doctrine_Table::getForeignKey -> Doctrine_Table::getRelation
parent
14781f1d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
40 additions
and
34 deletions
+40
-34
Collection.php
Doctrine/Collection.php
+2
-2
Connection.php
Doctrine/Connection.php
+3
-3
Mysql.php
Doctrine/Connection/Mysql.php
+2
-3
Hydrate.php
Doctrine/Hydrate.php
+3
-3
Query.php
Doctrine/Query.php
+2
-2
Record.php
Doctrine/Record.php
+4
-4
Session.php
Doctrine/Session.php
+3
-3
Table.php
Doctrine/Table.php
+4
-4
Validator.php
Doctrine/Validator.php
+9
-2
QueryTestCase.php
tests/QueryTestCase.php
+2
-2
RecordTestCase.php
tests/RecordTestCase.php
+3
-3
TableTestCase.php
tests/TableTestCase.php
+3
-3
No files found.
Doctrine/Collection.php
View file @
c9291743
...
...
@@ -540,7 +540,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
$query
;
}
$rel
=
$this
->
table
->
get
ForeignKey
(
$name
);
$rel
=
$this
->
table
->
get
Relation
(
$name
);
$table
=
$rel
->
getTable
();
$foreign
=
$rel
->
getForeign
();
$local
=
$rel
->
getLocal
();
...
...
@@ -570,7 +570,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @return void
*/
public
function
populateRelated
(
$name
,
Doctrine_Collection
$coll
)
{
$rel
=
$this
->
table
->
get
ForeignKey
(
$name
);
$rel
=
$this
->
table
->
get
Relation
(
$name
);
$table
=
$rel
->
getTable
();
$foreign
=
$rel
->
getForeign
();
$local
=
$rel
->
getLocal
();
...
...
Doctrine/Connection.php
View file @
c9291743
...
...
@@ -270,7 +270,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
//print "$k -- adding <b>$nm</b>...<br \>";
}
$rels
=
$table
->
get
ForeignKey
s
();
$rels
=
$table
->
get
Relation
s
();
// group relations
...
...
@@ -715,7 +715,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
final
public
function
saveRelated
(
Doctrine_Record
$record
)
{
$saveLater
=
array
();
foreach
(
$record
->
getReferences
()
as
$k
=>
$v
)
{
$fk
=
$record
->
getTable
()
->
get
ForeignKey
(
$k
);
$fk
=
$record
->
getTable
()
->
get
Relation
(
$k
);
if
(
$fk
instanceof
Doctrine_ForeignKey
||
$fk
instanceof
Doctrine_LocalKey
)
{
switch
(
$fk
->
getType
())
:
...
...
@@ -849,7 +849,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return void
*/
final
public
function
deleteComposites
(
Doctrine_Record
$record
)
{
foreach
(
$record
->
getTable
()
->
get
ForeignKey
s
()
as
$fk
)
{
foreach
(
$record
->
getTable
()
->
get
Relation
s
()
as
$fk
)
{
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
...
...
Doctrine/Connection/Mysql.php
View file @
c9291743
...
...
@@ -13,7 +13,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$pdo
->
setAttribute
(
PDO
::
ATTR_EMULATE_PREPARES
,
true
);
$this
->
setAttribute
(
Doctrine
::
ATTR_QUERY_LIMIT
,
Doctrine
::
LIMIT_ROWS
);
parent
::
__construct
(
$manager
,
$pdo
);
}
}
/**
* deletes all data access object from the collection
* @param Doctrine_Collection $coll
...
...
@@ -24,7 +24,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$a = $coll->getTable()->getCompositePaths();
$a = array_merge(array($coll->getTable()->getComponentName()),$a);
$graph = new Doctrine_
DQL_Parser($this
);
$graph = new Doctrine_
Query(
);
foreach($coll as $k=>$record) {
switch($record->getState()):
case Doctrine_Record::STATE_DIRTY:
...
...
@@ -44,7 +44,6 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
return $ids;
}
*/
/**
* returns maximum identifier values
*
...
...
Doctrine/Hydrate.php
View file @
c9291743
...
...
@@ -293,7 +293,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$prev
[
$root
]
=
$coll
;
if
(
$this
->
aggregate
)
if
(
$this
->
aggregate
)
$return
=
Doctrine
::
FETCH_ARRAY
;
$array
=
$this
->
parseData
(
$stmt
);
...
...
@@ -341,7 +341,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$tmp
=
explode
(
"."
,
$path
);
$alias
=
end
(
$tmp
);
unset
(
$tmp
);
$fk
=
$this
->
tables
[
$pointer
]
->
get
ForeignKey
(
$alias
);
$fk
=
$this
->
tables
[
$pointer
]
->
get
Relation
(
$alias
);
if
(
!
isset
(
$prev
[
$pointer
])
)
continue
;
...
...
@@ -389,7 +389,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$tmp
=
explode
(
"."
,
$path
);
$alias
=
end
(
$tmp
);
unset
(
$tmp
);
$fk
=
$this
->
tables
[
$pointer
]
->
get
ForeignKey
(
$alias
);
$fk
=
$this
->
tables
[
$pointer
]
->
get
Relation
(
$alias
);
$last
=
$prev
[
$pointer
]
->
getLast
();
switch
(
$fk
->
getType
())
:
...
...
Doctrine/Query.php
View file @
c9291743
...
...
@@ -326,7 +326,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$field
=
$table
->
getTableName
()
.
'.'
.
$table
->
getIdentifier
();
array_unshift
(
$this
->
parts
[
'where'
],
$field
.
' IN ('
.
$subquery
.
')'
);
$modifyLimit
=
false
;
}
}
}
$q
.=
(
!
empty
(
$this
->
parts
[
'where'
]))
?
" WHERE "
.
implode
(
" AND "
,
$this
->
parts
[
"where"
])
:
''
;
...
...
@@ -649,7 +649,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$tname
=
$table
->
getTableName
();
$fk
=
$table
->
get
ForeignKey
(
$name
);
$fk
=
$table
->
get
Relation
(
$name
);
$name
=
$fk
->
getTable
()
->
getComponentName
();
$original
=
$fk
->
getTable
()
->
getTableName
();
...
...
Doctrine/Record.php
View file @
c9291743
...
...
@@ -670,7 +670,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
else
{
// if not found, throws InvalidKeyException
$fk
=
$this
->
table
->
get
ForeignKey
(
$name
);
$fk
=
$this
->
table
->
get
Relation
(
$name
);
// one-to-many or one-to-one relation
if
(
$fk
instanceof
Doctrine_ForeignKey
||
...
...
@@ -869,7 +869,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
saveAssociations
()
{
foreach
(
$this
->
table
->
get
ForeignKey
s
()
as
$fk
)
:
foreach
(
$this
->
table
->
get
Relation
s
()
as
$fk
)
:
$table
=
$fk
->
getTable
();
$name
=
$table
->
getComponentName
();
$alias
=
$this
->
table
->
getAlias
(
$name
);
...
...
@@ -1094,7 +1094,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
final
public
function
loadReference
(
$name
)
{
$fk
=
$this
->
table
->
get
ForeignKey
(
$name
);
$fk
=
$this
->
table
->
get
Relation
(
$name
);
$table
=
$fk
->
getTable
();
$local
=
$fk
->
getLocal
();
...
...
@@ -1267,7 +1267,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer
*/
public
function
countRelated
(
$name
)
{
$rel
=
$this
->
table
->
get
ForeignKey
(
$name
);
$rel
=
$this
->
table
->
get
Relation
(
$name
);
$componentName
=
$rel
->
getTable
()
->
getComponentName
();
$alias
=
$rel
->
getTable
()
->
getAlias
(
get_class
(
$this
));
$query
=
new
Doctrine_Query
();
...
...
Doctrine/Session.php
View file @
c9291743
...
...
@@ -270,7 +270,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
//print "$k -- adding <b>$nm</b>...<br \>";
}
$rels
=
$table
->
get
ForeignKey
s
();
$rels
=
$table
->
get
Relation
s
();
// group relations
...
...
@@ -715,7 +715,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
final
public
function
saveRelated
(
Doctrine_Record
$record
)
{
$saveLater
=
array
();
foreach
(
$record
->
getReferences
()
as
$k
=>
$v
)
{
$fk
=
$record
->
getTable
()
->
get
ForeignKey
(
$k
);
$fk
=
$record
->
getTable
()
->
get
Relation
(
$k
);
if
(
$fk
instanceof
Doctrine_ForeignKey
||
$fk
instanceof
Doctrine_LocalKey
)
{
switch
(
$fk
->
getType
())
:
...
...
@@ -849,7 +849,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
* @return void
*/
final
public
function
deleteComposites
(
Doctrine_Record
$record
)
{
foreach
(
$record
->
getTable
()
->
get
ForeignKey
s
()
as
$fk
)
{
foreach
(
$record
->
getTable
()
->
get
Relation
s
()
as
$fk
)
{
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
...
...
Doctrine/Table.php
View file @
c9291743
...
...
@@ -363,7 +363,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$name
=
$this
->
getComponentName
();
foreach
(
$this
->
bound
as
$k
=>
$a
)
{
try
{
$fk
=
$this
->
get
ForeignKey
(
$k
);
$fk
=
$this
->
get
Relation
(
$k
);
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
...
...
@@ -540,7 +540,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @param string $name component name of which a foreign key object is bound
* @return Doctrine_Relation
*/
final
public
function
get
ForeignKey
(
$name
)
{
final
public
function
get
Relation
(
$name
)
{
$original
=
$name
;
if
(
isset
(
$this
->
relations
[
$name
]))
...
...
@@ -624,10 +624,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*
* @return array
*/
final
public
function
get
ForeignKey
s
()
{
final
public
function
get
Relation
s
()
{
$a
=
array
();
foreach
(
$this
->
bound
as
$k
=>
$v
)
{
$this
->
get
ForeignKey
(
$k
);
$this
->
get
Relation
(
$k
);
}
return
$this
->
relations
;
...
...
Doctrine/Validator.php
View file @
c9291743
...
...
@@ -158,14 +158,21 @@ class Doctrine_Validator {
$err
[
$key
]
=
Doctrine_Validator
::
ERR_LENGTH
;
continue
;
}
if
(
!
is_array
(
$column
[
2
]))
$e
=
explode
(
"|"
,
$column
[
2
]);
else
$e
=
$column
[
2
];
$e
=
explode
(
"|"
,
$column
[
2
]);
foreach
(
$e
as
$k
=>
$arg
)
{
if
(
empty
(
$arg
)
||
$arg
==
"primary"
||
$arg
==
"protected"
||
$arg
==
"autoincrement"
)
continue
;
$args
=
explode
(
":"
,
$arg
);
if
(
!
is_integer
(
$k
))
{
$args
=
$arg
;
}
else
$args
=
explode
(
":"
,
$arg
);
if
(
!
isset
(
$args
[
1
]))
$args
[
1
]
=
''
;
...
...
tests/QueryTestCase.php
View file @
c9291743
...
...
@@ -874,14 +874,14 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$board
=
new
Forum_Board
();
$table
=
$board
->
getTable
();
$fk
=
$table
->
get
ForeignKey
(
"Threads"
);
$fk
=
$table
->
get
Relation
(
"Threads"
);
$this
->
assertEqual
(
$table
->
getComponentName
(),
"Forum_Board"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertEqual
(
$fk
->
getTable
()
->
getComponentName
(),
"Forum_Thread"
);
$entry
=
new
Forum_Entry
();
$this
->
assertTrue
(
$entry
->
getTable
()
->
get
ForeignKey
(
"Thread"
)
instanceof
Doctrine_LocalKey
);
$this
->
assertTrue
(
$entry
->
getTable
()
->
get
Relation
(
"Thread"
)
instanceof
Doctrine_LocalKey
);
$board
->
name
=
"Doctrine Forum"
;
...
...
tests/RecordTestCase.php
View file @
c9291743
...
...
@@ -369,7 +369,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
public
function
testTreeStructure
()
{
$e
=
new
Element
();
$fk
=
$e
->
getTable
()
->
get
ForeignKey
(
"Child"
);
$fk
=
$e
->
getTable
()
->
get
Relation
(
"Child"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertEqual
(
$fk
->
getType
(),
Doctrine_Relation
::
MANY_AGGREGATE
);
$this
->
assertEqual
(
$fk
->
getForeign
(),
"parent_id"
);
...
...
@@ -438,7 +438,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$e2
->
message
,
"user error2"
);
$fk
=
$e
->
getTable
()
->
get
ForeignKey
(
"Description"
);
$fk
=
$e
->
getTable
()
->
get
Relation
(
"Description"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertEqual
(
$fk
->
getLocal
(),
"file_md5"
);
$this
->
assertEqual
(
$fk
->
getForeign
(),
"file_md5"
);
...
...
@@ -756,7 +756,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
// ACCESSING ASSOCIATION OBJECT PROPERTIES
$user
=
new
User
();
$this
->
assertTrue
(
$user
->
getTable
()
->
get
ForeignKey
(
"Groupuser"
)
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$user
->
getTable
()
->
get
Relation
(
"Groupuser"
)
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$user
->
Groupuser
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$user
->
Groupuser
[
0
]
instanceof
Groupuser
);
...
...
tests/TableTestCase.php
View file @
c9291743
...
...
@@ -9,14 +9,14 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$table
=
$this
->
connection
->
getTable
(
"User"
);
}
public
function
testGetForeignKey
()
{
$fk
=
$this
->
objTable
->
get
ForeignKey
(
"Group"
);
$fk
=
$this
->
objTable
->
get
Relation
(
"Group"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_Association
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
MANY_AGGREGATE
);
$this
->
assertTrue
(
$fk
->
getLocal
()
==
"user_id"
);
$this
->
assertTrue
(
$fk
->
getForeign
()
==
"group_id"
);
$fk
=
$this
->
objTable
->
get
ForeignKey
(
"Email"
);
$fk
=
$this
->
objTable
->
get
Relation
(
"Email"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_LocalKey
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
ONE_COMPOSITE
);
...
...
@@ -24,7 +24,7 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$fk
->
getForeign
()
==
$fk
->
getTable
()
->
getIdentifier
());
$fk
=
$this
->
objTable
->
get
ForeignKey
(
"Phonenumber"
);
$fk
=
$this
->
objTable
->
get
Relation
(
"Phonenumber"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
MANY_COMPOSITE
);
...
...
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