Location: PHPKode > projects > Test Suites Results Parser and Browser > tslogparser-v07/db/update_db.inc.php
<?php
/*
 * Copyright (c) 2005, Bull S.A..  All rights reserved.
 * Created by: Sebastien Decugis
 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write the Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
 */

/* This file defines the function update_db() */

define('LATEST_VERSION', "2");

/* Example of update routine */
// function db_v1_to_v2()
// {
// 	$queries=array();
//	$queries[]="ALTER TABLE opts_domain add (dom_type int, dom_owner varchar(10))";
//	$queries[]="UPDATE opts_config SET cfg_val='2' WHERE cfg_key='version'";
//	execute_update_queries($queries);
// }


function db_v1_to_v2()
{
	$queries=array();
	$queries[]="ALTER TABLE `opts_run_results` CHANGE `res_log` `res_log` LONGTEXT DEFAULT NULL";
	$queries[]="UPDATE opts_config SET cfg_val='2' WHERE cfg_key='version'";
	execute_update_queries($queries);
}




function update_db( $curver = 1 )
{
	$tmpver = $curver;

	/* This is the template for future database updates */
	if ($tmpver == 1)
		$tmpver = db_v1_to_v2();
//	if ($tmpver == 2)
//		$tmpver = db_v2_to_v3();
//      ...

}

function execute_update_queries(&$queries)
{
	foreach ($queries as $sql)
		mysql_query($sql) or die("Unexpected error: ".mysql_error());
}



?>
Return current item: Test Suites Results Parser and Browser