Kyberia v2.3 - 1st revision from SVN (Without patches of kyberia.sk team)
[mirrors/Kyberia-bloodline.git] / scripts / descendantcounter.php
diff --git a/scripts/descendantcounter.php b/scripts/descendantcounter.php
new file mode 100644 (file)
index 0000000..f17786e
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+//requiring main config file with path/database etc. constants
+require('../config/config.inc');
+
+//connecting to database and creating universal $db object
+require(SYSTEM_ROOT.'/inc/log.inc');
+require(SYSTEM_ROOT.'/inc/database.inc');
+require(SYSTEM_ROOT.'/inc/nodes.inc');
+$db=new CLASS_DATABASE();
+
+$set=$db->query("select node_thread_vector,node_id from nodes");
+while ($set->next()) {
+       unset($pocet);
+       $ancestor=$set->getString('node_id');
+       $vector=$set->getString('node_thread_vector');
+       $countset=$db->query("select count(*) as pocet from nodes where node_thread_vector like '$vector;$ancestor'");
+       $countset->next(); $pocet=$countset->getString('pocet');
+       $countset=$db->query("select count(*) as pocet from nodes where node_thread_vector like '$vector;$ancestor;%'");
+       $countset->next(); $pocet+=$countset->getString('pocet');
+       $db->query("update nodes set node_descendant_count='$pocet' where node_id='$ancestor'");
+}
+
+?>
+
This page took 0.089758 seconds and 4 git commands to generate.