function insertSiblingData($FieldValueArray=array(),$ConditionString=null,$Rest=null)
    {
		$this->lock();
    	//Find the Sibling
        $Arguments=func_get_args();
        array_shift($Arguments); //first argument, the array
        array_shift($Arguments);
        if ($ConditionString) $ConditionString="WHERE $ConditionString";
        $Query="SELECT {$this->right()} AS `Right`".
        	" FROM {$this->table()} $ConditionString";

        array_unshift($Arguments,$Query);
        $Sibl=call_user_func_array("Jf::sql",$Arguments);

        $Sibl=$Sibl[0];
        if ($Sibl==null)
        {
            $Sibl["Left"]=$Sibl["Right"]=0;
        }
        Jf::sql("UPDATE {$this->table()} SET {$this->right()} = {$this->right()} + 2 WHERE {$this->right()} > ?",$Sibl["Right"]);
        Jf::sql("UPDATE {$this->table()} SET {$this->left()} = {$this->left()} + 2 WHERE {$this->left()} > ?",$Sibl["Right"]);

        $FieldsString=$ValuesString="";
        $Values=array();
        if ($FieldValueArray)
        foreach($FieldValueArray as $k=>$v)
        {
            $FieldsString.=",";
            $FieldsString.="`".$k."`";
            $ValuesString.=",?";
            $Values[]=$v;
        }

        $Query= "INSERT INTO {$this->table()} ({$this->left()},{$this->right()} $FieldsString) ".
        	"VALUES(?,? $ValuesString)";
        array_unshift($Values,$Sibl["Right"]+2);
        array_unshift($Values,$Sibl["Right"]+1);
        array_unshift($Values,$Query);

        $Res=call_user_func_array("Jf::sql",$Values);
		$this->unlock();
        return $Res;
    }
function insertSiblingData($FieldValueArray=array(),$ConditionString=null,$Rest=null)
    {
		$this->lock();
    	//Find the Sibling
        $Arguments=func_get_args();
        array_shift($Arguments); //first argument, the array
        array_shift($Arguments);
        if ($ConditionString) $ConditionString="WHERE $ConditionString";
        $Query="SELECT {$this->right()} AS `Right`".
        	" FROM {$this->table()} $ConditionString";

        array_unshift($Arguments,$Query);
        $Sibl=call_user_func_array("Jf::sql",$Arguments);

        $Sibl=$Sibl[0];
        if ($Sibl==null)
        {
            $Sibl["Left"]=$Sibl["Right"]=0;
        }
        Jf::sql("UPDATE {$this->table()} SET {$this->right()} = {$this->right()} + 2 WHERE {$this->right()} > ?",$Sibl["Right"]);
        Jf::sql("UPDATE {$this->table()} SET {$this->left()} = {$this->left()} + 2 WHERE {$this->left()} > ?",$Sibl["Right"]);

        $FieldsString=$ValuesString="";
        $Values=array();
        if ($FieldValueArray)
        foreach($FieldValueArray as $k=>$v)
        {
            $FieldsString.=",";
            $FieldsString.="`".$k."`";
            $ValuesString.=",?";
            $Values[]=$v;
        }

        $Query= "INSERT INTO {$this->table()} ({$this->left()},{$this->right()} $FieldsString) ".
        	"VALUES(?,? $ValuesString)";
        array_unshift($Values,$Sibl["Right"]+2);
        array_unshift($Values,$Sibl["Right"]+1);
        array_unshift($Values,$Query);

        $Res=call_user_func_array("Jf::sql",$Values);
		$this->unlock();
        return $Res;
    }
function insertSiblingData ( $ FieldValueArray = array ( ) , $ ConditionString = null , $ Rest = null ) { $ this -> lock ( ) ; //Find the Sibling $ Arguments = func_get_args ( ) ; array_shift ( $ Arguments ) ; //first argument, the array array_shift ( $ Arguments ) ; if ( $ ConditionString ) $ ConditionString = "WHERE $ConditionString" ; $ Query = "SELECT {$this->right()} AS `Right`" . " FROM {$this->table()} $ConditionString" ; array_unshift ( $ Arguments , $ Query ) ; $ Sibl = call_user_func_array ( "Jf::sql" , $ Arguments ) ; $ Sibl = $ Sibl [ 0 ] ; if ( $ Sibl == null ) { $ Sibl [ "Left" ] = $ Sibl [ "Right" ] = 0 ; } Jf :: sql ( "UPDATE {$this->table()} SET {$this->right()} = {$this->right()} + 2 WHERE {$this->right()} > ?" , $ Sibl [ "Right" ] ) ; Jf :: sql ( "UPDATE {$this->table()} SET {$this->left()} = {$this->left()} + 2 WHERE {$this->left()} > ?" , $ Sibl [ "Right" ] ) ; $ FieldsString = $ ValuesString = "" ; $ Values = array ( ) ; if ( $ FieldValueArray ) foreach ( $ FieldValueArray as $ k => $ v ) { $ FieldsString .= "," ; $ FieldsString .= "`" . $ k . "`" ; $ ValuesString .= ",?" ; $ Values [ ] = $ v ; } $ Query = "INSERT INTO {$this->table()} ({$this->left()},{$this->right()} $FieldsString) " . "VALUES(?,? $ValuesString)" ; array_unshift ( $ Values , $ Sibl [ "Right" ] + 2 ) ; array_unshift ( $ Values , $ Sibl [ "Right" ] + 1 ) ; array_unshift ( $ Values , $ Query ) ; $ Res = call_user_func_array ( "Jf::sql" , $ Values ) ; $ this -> unlock ( ) ; return $ Res ; }
Adds a sibling after a node

@param array $FieldValueArray Pairs of Key/Value as Field/Value in the table
@param string $ConditionString
@param string $Rest optional, rest of variables to fill in placeholders of condition string
@return Integer SiblingID
Adds a sibling after a node