File: fixboxlist.pl

package info (click to toggle)
pronto 2.4.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,112 kB
  • ctags: 488
  • sloc: perl: 22,159; makefile: 140; sh: 34; sql: 7
file content (32 lines) | stat: -rwxr-xr-x 762 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use File::Copy;
require "prontolib.pl";
&read_prefs();

$conn=&open_db_conn;

&fix_boxlist;

sub fix_boxlist
{
	my($parent) = @_;
	my($sql,$query,$query2,@row,$lastid);
	if(defined $parent) {
		$sql = "select id,sibling,parent from boxlist where parent=? order by id desc";
		$query=$main::conn->prepare($sql);
		$query->execute($parent);
	}
	else {
		$sql = "select id,sibling,parent from boxlist where (parent=-1 or parent is NULL) order by id desc";
		$query=$main::conn->prepare($sql);
		$query->execute();
	}
	$lastid=65535;
	while(@row=$query->fetchrow_array()) {
		$sql = "update boxlist set sibling=? where id=?";
		$query2=$main::conn->prepare($sql);
		$query2->execute($lastid,$row[0]);
		$lastid=$row[0];
		&fix_boxlist($row[0]);
	}
}