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
73985fe6
Commit
73985fe6
authored
Aug 22, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added mapping check to onetomany. corrected test models.
parent
0b80ec0b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
8 deletions
+33
-8
OneToMany.php
lib/Doctrine/Association/OneToMany.php
+18
-0
MappingException.php
lib/Doctrine/MappingException.php
+5
-0
CmsArticle.php
tests/models/cms/CmsArticle.php
+1
-0
CmsComment.php
tests/models/cms/CmsComment.php
+6
-0
ForumBoard.php
tests/models/forum/ForumBoard.php
+1
-4
ForumCategory.php
tests/models/forum/ForumCategory.php
+2
-4
No files found.
lib/Doctrine/Association/OneToMany.php
View file @
73985fe6
...
...
@@ -67,6 +67,24 @@ class Doctrine_Association_OneToMany extends Doctrine_Association
$this
->
_isOwningSide
=
false
;
}
/**
* Validates and completed the mapping.
*
* @param array $mapping The mapping to validate and complete.
* @return array The validated and completed mapping.
* @override
*/
protected
function
_validateAndCompleteMapping
(
array
$mapping
)
{
$mapping
=
parent
::
_validateAndCompleteMapping
(
$mapping
);
// one-side MUST be inverse (must have mappedBy)
if
(
!
isset
(
$mapping
[
'mappedBy'
]))
{
throw
Doctrine_MappingException
::
oneToManyRequiresMappedBy
(
$mapping
[
'fieldName'
]);
}
return
$mapping
;
}
/**
* Whether orphaned elements (removed from the collection) should be deleted.
*
...
...
lib/Doctrine/MappingException.php
View file @
73985fe6
...
...
@@ -47,6 +47,11 @@ class Doctrine_MappingException extends Doctrine_Exception
{
return
new
self
(
"No mapping found for field '
$fieldName
'."
);
}
public
static
function
oneToManyRequiresMappedBy
(
$fieldName
)
{
return
new
self
(
"OneToMany mapping on field '
$fieldName
' requires the 'mappedBy' attribute."
);
}
}
?>
\ No newline at end of file
tests/models/cms/CmsArticle.php
View file @
73985fe6
...
...
@@ -39,6 +39,7 @@ class CmsArticle extends Doctrine_Entity
$mapping
->
mapOneToMany
(
array
(
'fieldName'
=>
'comments'
,
'targetEntity'
=>
'CmsComment'
,
'mappedBy'
=>
'article'
));
$mapping
->
mapManyToOne
(
array
(
...
...
tests/models/cms/CmsComment.php
View file @
73985fe6
...
...
@@ -34,5 +34,11 @@ class CmsComment extends Doctrine_Entity
'type'
=>
'integer'
,
'length'
=>
4
));
$mapping
->
mapManyToOne
(
array
(
'fieldName'
=>
'article'
,
'targetEntity'
=>
'CmsArticle'
,
'joinColumns'
=>
array
(
'article_id'
=>
'id'
)
));
}
}
tests/models/forum/ForumBoard.php
View file @
73985fe6
...
...
@@ -25,10 +25,7 @@ class ForumBoard extends Doctrine_Entity
'type'
=>
'integer'
));
/*$mapping->hasOne('ForumCategory as category',
array('local' => 'category_id', 'foreign' => 'id'));*/
$mapping
->
mapOneToOne
(
array
(
$mapping
->
mapManyToOne
(
array
(
'fieldName'
=>
'category'
,
'targetEntity'
=>
'ForumCategory'
,
'joinColumns'
=>
array
(
'category_id'
=>
'id'
)
...
...
tests/models/forum/ForumCategory.php
View file @
73985fe6
...
...
@@ -20,12 +20,10 @@ class ForumCategory extends Doctrine_Entity
'length'
=>
255
));
/*$mapping->hasMany('ForumBoard as boards', array(
'local' => 'id' , 'foreign' => 'category_id'));*/
$mapping
->
mapOneToMany
(
array
(
'fieldName'
=>
'boards'
,
'targetEntity'
=>
'ForumBoard'
'targetEntity'
=>
'ForumBoard'
,
'mappedBy'
=>
'category'
));
}
}
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