diff -r 2cd8c1649ba9 -r 58094faf794d seq_update.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/seq_update.php Tue Apr 10 22:40:43 2007 +0000 @@ -0,0 +1,55 @@ + trancer nl> | +// | Sjeemz sjeemz nl> | +// +--------------------------------------------------------------------+ +// +// File: seq_update.php +// Description: synches your database after manual insertions. +// Doesnt do much, just searches the highest record_id and updates the seq table with this + +require_once("inc/toolkit.inc.php"); +require_once("inc/header.inc.php"); + +// Ok we have to synch it all. +// What to do? Find the MAX(id) on each table and set it to the _seq table. + +echo "

Synching databases. This is useful if you did manual insertions (in case you havent been here yet)

"; + +if(!level(10)) +{ + error(ERR_LEVEL_10); +} + +function seq_update(&$item) +{ + global $db; + $number_u = $db->getOne("SELECT MAX(id) FROM $item"); + if($number_u > 1) + { + echo $number_u; + $number_u_seq = $db->getOne("SELECT id FROM " . $item . "_seq"); + if($number_u_seq < $number_u) + { + $number_u += 1; + $db->query("UPDATE " . $item . "_seq SET id='$number_u'"); + } + } +} + +$tables = array('users', 'zones', 'records', 'domains'); + +array_walk($tables, 'seq_update'); + +message("All tables are successfully synchronized."); + +php?>