/** * @param Entity_Tree $elem * @return bool */ public function deleteTree($elem) { $rk = $elem->getRightKey(); $lk = $elem->getLeftKey(); $tree = new DAO_Tree(); $res = $tree->getChild($elem->getId()); $this->deleteChildFromTable($res); $del = $this->DB->prepare('DELETE FROM `site_tree` WHERE `left_key`>=:left AND `right_key`<=:right'); $del->bindParam(':left', $lk); $del->bindParam(':right', $rk); $q1 = $del->execute(); $del = $this->DB->prepare('UPDATE `site_tree` SET `right_key`=`right_key`-(:right-:left+1) WHERE `right_key`>:right AND `left_key`<:left'); $del->bindParam(':left', $lk); $del->bindParam(':right', $rk); $del->execute(); $del = $this->DB->prepare('UPDATE `site_tree` SET `left_key`=`left_key`-(:right-:left+1), `right_key`=`right_key`-(:right-:left+1) WHERE `left_key`>:right'); $del->bindParam(':left', $lk); $del->bindParam(':right', $rk); $del->execute(); return $q1; }