seq_update.php
author rejo
Tue, 17 Apr 2007 19:43:24 +0000
changeset 4 55ed92aa7cf5
parent 2 9a485c41cfcf
child 6 9fcac40c1b0e
permissions -rwxr-xr-x
[feladat @ 5] - Second half of translation framework. - Several small typo's in code fixed. - Removed comments on a todo in leveldescription(), already done. - Replaced dal.inc.php with DB.php from package DB-1.7.6 from pear.php.net to fix problems using poweradmin 1.2.7-patched with php5/pear. The DB package has already been superseded by MDB2, but that version is incompatible with current code.

<?php
// +--------------------------------------------------------------------+
// | PowerAdmin								|
// +--------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PowerAdmin Team			|
// +--------------------------------------------------------------------+
// | This source file is subject to the license carried by the overal	|
// | program PowerAdmin as found on http://poweradmin.sf.net		|
// | The PowerAdmin program falls under the QPL License:		|
// | http://www.trolltech.com/developer/licensing/qpl.html		|
// +--------------------------------------------------------------------+
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> 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 "<P><B>" . _('Synching databases. This is useful if you did manual insertions (in case you havent been here yet).') . "</B></P>";

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?>