|
@@ -34,7 +34,25 @@ class Relation
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- # 重置上级
|
|
|
+ # 更换上级 效率较高
|
|
|
+ public function replaceParent($uid, $old_parent, $new_parent)
|
|
|
+ {
|
|
|
+ $info = Dever::db('invite/relation')->find(array('to_uid' => $uid, 'uid' => $old_parent));
|
|
|
+ if ($info) {
|
|
|
+ $state = Dever::db('invite/relation')->update(array('where_id' => $info['id'], 'uid' => $new_parent));
|
|
|
+ if ($state) {
|
|
|
+ $child = $this->getChild($uid, 1);
|
|
|
+ if ($child) {
|
|
|
+ foreach ($child as $k => $v) {
|
|
|
+ $this->replaceParent($v['to_uid'], $old_parent, $new_parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ # 重置上级 效率较低
|
|
|
public function resetParent($uid, $parent)
|
|
|
{
|
|
|
Dever::db('invite/relation')->delete(array('to_uid' => $uid));
|