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
4b5731ba
Commit
4b5731ba
authored
May 08, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Doctrine_Node_NestedSet::delete() work correctly with multiple roots.
parent
86fe74d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
NestedSet.php
lib/Doctrine/Node/NestedSet.php
+14
-13
No files found.
lib/Doctrine/Node/NestedSet.php
View file @
4b5731ba
...
...
@@ -21,13 +21,14 @@
/**
* Doctrine_Node_NestedSet
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Joe Simms <joe.simms@websites4.com>
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Joe Simms <joe.simms@websites4.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class
Doctrine_Node_NestedSet
extends
Doctrine_Node
implements
Doctrine_Node_Interface
{
...
...
@@ -544,7 +545,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
*
* @todo Exception handling/wrapping
*/
public
function
makeRoot
()
public
function
makeRoot
(
$newRootId
)
{
// TODO: throw exception instead?
if
(
$this
->
getLeftValue
()
==
1
||
!
$this
->
record
->
getTable
()
->
getTree
()
->
getAttribute
(
'hasManyRoots'
))
{
...
...
@@ -567,11 +568,11 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
// Set new lft/rgt/root values for root node
$this
->
setLeftValue
(
1
);
$this
->
setRightValue
(
$oldRgt
-
$oldLft
+
1
);
$this
->
setRootValue
(
$
this
->
record
->
i
d
);
$this
->
setRootValue
(
$
newRootI
d
);
// Update descendants lft/rgt/root values
$diff
=
1
-
$oldLft
;
$newRoot
=
$
this
->
record
->
i
d
;
$newRoot
=
$
newRootI
d
;
$componentName
=
$this
->
record
->
getTable
()
->
getComponentName
();
$rootColName
=
$this
->
record
->
getTable
()
->
getTree
()
->
getAttribute
(
'rootColumnName'
);
$q
=
$this
->
record
->
getTable
()
->
createQuery
();
...
...
@@ -671,14 +672,14 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public
function
delete
()
{
// TODO: add the setting whether or not to delete descendants or relocate children
$oldRoot
=
$this
->
getRootValue
();
$q
=
$this
->
record
->
getTable
()
->
createQuery
();
$componentName
=
$this
->
record
->
getTable
()
->
getComponentName
();
$q
=
$q
->
where
(
$componentName
.
'.lft >= ? AND '
.
$componentName
.
'.rgt <= ?'
,
array
(
$this
->
getLeftValue
(),
$this
->
getRightValue
()));
$q
=
$this
->
record
->
getTable
()
->
getTree
()
->
returnQueryWithRootId
(
$q
,
$
this
->
getRootValue
()
);
$q
=
$this
->
record
->
getTable
()
->
getTree
()
->
returnQueryWithRootId
(
$q
,
$
oldRoot
);
$coll
=
$q
->
execute
();
...
...
@@ -686,7 +687,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
$first
=
$this
->
getRightValue
()
+
1
;
$delta
=
$this
->
getLeftValue
()
-
$this
->
getRightValue
()
-
1
;
$this
->
shiftRLValues
(
$first
,
$delta
);
$this
->
shiftRLValues
(
$first
,
$delta
,
$oldRoot
);
return
true
;
}
...
...
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