TABLE_STUFF
~~~~~~~~~~~~~~~~~~~~
ID (pk)
name
parent_ID
####
TABLE_STUFF
~~~~~~~~~~~~~~~~~~~~
ID (pk)
name
parent_ID
lft
rght
depth
lineage
####
sub rebuild_tree
{
my $dbh = shift;
my $dir_ID = shift;
my $left = shift;
my $right = $left + 1;
my $sql = "select ID, name from DIRECTORIES where parent_ID = ?";
my $sth = $dbh->prepare($sql);
$sth->execute($dir_ID) || return $right + 1;
my $row;
while($row = $sth->fetchrow_arrayref)
{
#print STDERR "Processing: ", $row->[0], " with name: ", $row->[1],"\n";
$right = rebuild_tree($dbh, $row->[0], $right);
}
my $sql2 = "update DIRECTORIES set lft = ?, rght = ? where ID = ?";
my $sth2 = $dbh->prepare($sql2);
$sth2->execute($left, $right, $dir_ID);
return $right + 1;
}
####
use vars qw($sth);
....
# And then in the function
$sth || = $dbh->prepare($sql);
####
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute()