--- ./old/Dynamic/DBnested.php 2003-07-24 15:49:09.000000000 +0200 +++ ./new/Dynamic/DBnested.php 2003-12-02 17:12:16.000000000 +0100 @@ -16,10 +16,9 @@ // | Authors: | // +----------------------------------------------------------------------+ // -// $Id: DBnested.php,v 1.34 2003/07/24 08:18:23 cain Exp $ +// $Id: DBnested.php,v 1.30 2003/07/03 11:51:10 cain Exp $ -require_once 'Tree/Tree.php'; -require_once 'Tree/Common.php'; +require_once 'Tree/OptionsDB.php'; /** * This class implements methods to work on a tree saved using the nested @@ -29,10 +28,7 @@ * @access public * @package Tree */ -class Tree_Dynamic_DBnested extends Tree_Common -// FIXXME should actually extend Tree_Common, to use the methods provided -// in there... but we need to connect to the db here, so we extend optionsDB -// for now, may be use "aggregate" function to fix that +class Tree_Dynamic_DBnested extends Tree_OptionsDB { // {{{ properties @@ -216,7 +212,7 @@ // commit here return $nextId; - } // end of function + } // }}} // {{{ _add() @@ -243,7 +239,8 @@ // update the elements which will be affected by the new insert $query = sprintf( 'UPDATE %s SET %s=%s+%s WHERE%s %s>%s', $this->table, - $lName,$lName, + $lName, + $lName, $numberOfElements*2, $this->_getWhereAddOn(), $lName, @@ -584,7 +581,7 @@ */ function update($id,$newValues) { - // jsut to be sure nothing gets screwed up :-) + // just to be sure nothing gets screwed up :-) unset($newValues[$this->_getColName('left')]); unset($newValues[$this->_getColName('right')]); unset($newValues[$this->_getColName('parentId')]); @@ -1059,8 +1056,8 @@ $child = $this->getElement($childId); if ($parent['left'] < $child['left'] - && - $parent['right'] > $child['right']) { + && $parent['right'] > $child['right']) + { return true; } return false; @@ -1079,6 +1076,7 @@ */ function getDepth() { + // FIXXXME TODO!!! $query = sprintf( 'SELECT COUNT(*) FROM %s p, %s e '. 'WHERE %s (e.%s BETWEEN p.%s AND p.%s) AND '. '(e.%s BETWEEN p.%s AND p.%s)', @@ -1116,7 +1114,7 @@ { $element = $this->getElement($id); // if the diff between left and right>1 then there are children - return $element['right']-$element['left']>1; + return ($element['right'] - $element['left']) > 1; } // }}} @@ -1142,7 +1140,7 @@ */ function getIdByPath($path, $startId=0, $nodeName='name', $separator='/') // should this method be called getElementIdByPath ???? - // Yes, with an optionnal private paramater to get the whole node + // Yes, with an optional private paramater to get the whole node // in preference to only the id? { if($separator=='') {