sugestia nr 1
Zmien metode newCHild na
<?php
function newChild( $name, $parentId ){
$parent = $this->db->getRow(\"select cluster, LEFT(level, depth*2) as cutLevel, depth FROM \".$this->table.\"
WHERE RIGHT(level,2) != '99' AND
id=\".$parentId);
if(!$parent){return false;}
print \"select \".$parent['cluster'].\", '\".$name.\"', RPAD( CONCAT( '\".$parent['cutLevel'].\"' ,LPAD( SUBSTRING(g.level, (\".$parent['depth'].\"*2)+1, 2 ) + 1, 2, '0')), \". $this->levelNum .\", '0'),\".$parent['depth'].\"+1 FROM \".$this->table.\" AS g
LEFT
JOIN \".$this->table.\" AS p ON CONCAT(g.cluster,'|',RPAD( CONCAT( '\".$parent['cutLevel'].\"' ,LPAD( SUBSTRING(g.level, (\".$parent['depth'].\"*2)+1, 2 ) + 1, 2, '0')), \". $this->levelNum .\", '0')) = CONCAT(p.cluster,'|',p.level)where g.cluster = \".$parent['cluster'].\" and
g.level like CONCAT( '\".$parent['cutLevel'].\"','%') and
(\".$parent['depth'].\"*2) + 2 <= \".$this->levelNum.\" and
p.level is null
LIMIT 1\";
return $this->db->execute(\" insert into \".$this->table.\" (cluster, name, level, depth ) select \".$parent['cluster'].\", '\".$name.\"', RPAD( CONCAT( '\".$parent['cutLevel'].\"' ,LPAD( SUBSTRING(g.level, (\".$parent['depth'].\"*2)+1, 2 ) + 1, 2, '0')), \". $this->levelNum .\", '0'),\".$parent['depth'].\"+1
FROM \".$this->table.\" AS g
LEFT
JOIN \".$this->table.\" AS p ON CONCAT(g.cluster,'|',RPAD( CONCAT( '\".$parent['cutLevel'].\"' ,LPAD( SUBSTRING(g.level, (\".$parent['depth'].\"*2)+1, 2 ) + 1, 2, '0')), \". $this->levelNum .\", '0')) = CONCAT(p.cluster,'|',p.level)where g.cluster = \".$parent['cluster'].\" and
g.level like CONCAT( '\".$parent['cutLevel'].\"','%') and
(\".$parent['depth'].\"*2) + 2 <= \".$this->levelNum.\" and
p.level is null
LIMIT 1\");
}
?>
Zobacz czy wyprintowane zapytanie dziala na bazie danych czy nie wywala bledow. I co wazniejsze czy zwraca jakis rezultat.
Jesli nie to:
sugestia nr 2
Jesli mozesz to daj link do zrzutu bazy.