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
404338f4
Commit
404338f4
authored
Sep 12, 2007
by
jackbravo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for unlink all
parent
c8578d43
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
Record.php
lib/Doctrine/Record.php
+12
-5
RecordTestCase.php
tests/RecordTestCase.php
+7
-0
No files found.
lib/Doctrine/Record.php
View file @
404338f4
...
@@ -1456,12 +1456,13 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1456,12 +1456,13 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
/**
/**
* removeLinks
* removeLinks
* removes links from this record to given records
* removes links from this record to given records
* if no ids are given, it removes all links
*
*
* @param string $alias related component alias
* @param string $alias related component alias
* @param array $ids the identifiers of the related records
* @param array $ids the identifiers of the related records
* @return Doctrine_Record this object
* @return Doctrine_Record this object
*/
*/
public
function
unlink
(
$alias
,
$ids
)
public
function
unlink
(
$alias
,
$ids
=
array
()
)
{
{
$ids
=
(
array
)
$ids
;
$ids
=
(
array
)
$ids
;
...
@@ -1472,8 +1473,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1472,8 +1473,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
if
(
$rel
instanceof
Doctrine_Relation_Association
)
{
if
(
$rel
instanceof
Doctrine_Relation_Association
)
{
$q
->
delete
()
$q
->
delete
()
->
from
(
$rel
->
getAssociationTable
()
->
getComponentName
())
->
from
(
$rel
->
getAssociationTable
()
->
getComponentName
())
->
where
(
$rel
->
getLocal
()
.
' = ?'
,
array_values
(
$this
->
identifier
()))
->
where
(
$rel
->
getLocal
()
.
' = ?'
,
array_values
(
$this
->
identifier
()));
->
whereIn
(
$rel
->
getForeign
(),
$ids
);
if
(
count
(
$ids
)
>
0
)
{
$q
->
whereIn
(
$rel
->
getForeign
(),
$ids
);
}
$q
->
execute
();
$q
->
execute
();
...
@@ -1481,8 +1485,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1481,8 +1485,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
elseif
(
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
}
elseif
(
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
$q
->
update
(
$rel
->
getTable
()
->
getComponentName
())
$q
->
update
(
$rel
->
getTable
()
->
getComponentName
())
->
set
(
$rel
->
getForeign
(),
'?'
,
array
(
null
))
->
set
(
$rel
->
getForeign
(),
'?'
,
array
(
null
))
->
addWhere
(
$rel
->
getForeign
()
.
' = ?'
,
array_values
(
$this
->
identifier
()))
->
addWhere
(
$rel
->
getForeign
()
.
' = ?'
,
array_values
(
$this
->
identifier
()));
->
whereIn
(
$rel
->
getTable
()
->
getIdentifier
(),
$ids
);
if
(
count
(
$ids
)
>
0
)
{
$q
->
whereIn
(
$rel
->
getTable
()
->
getIdentifier
(),
$ids
);
}
$q
->
execute
();
$q
->
execute
();
}
}
...
...
tests/RecordTestCase.php
View file @
404338f4
...
@@ -793,6 +793,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
...
@@ -793,6 +793,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$user
->
Group
[
0
]
->
identifier
(),
$group1
->
identifier
());
$this
->
assertEqual
(
$user
->
Group
[
0
]
->
identifier
(),
$group1
->
identifier
());
$this
->
assertEqual
(
$user
->
Group
[
1
]
->
identifier
(),
$group2
->
identifier
());
$this
->
assertEqual
(
$user
->
Group
[
1
]
->
identifier
(),
$group2
->
identifier
());
$user
->
unlink
(
'Group'
);
$user
->
save
();
unset
(
$user
);
$user
=
$this
->
objTable
->
find
(
5
);
$this
->
assertEqual
(
$user
->
Group
->
count
(),
0
);
// ACCESSING ASSOCIATION OBJECT PROPERTIES
// ACCESSING ASSOCIATION OBJECT PROPERTIES
...
...
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