From 3904e2d9d89121f75ba94c630be3f60e62399903 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 16 Nov 2007 21:42:45 +0000 Subject: [PATCH] - Allow the update script to include a PHP script too. The PHP script, called db.update.$num.php, may contain 2 functions db_update_pre() and db_update_post() which are run before(pre) and after(post) the SQL file is applied. If the php script doesn't exist, the behaviour of the update script is unchanged. --- db/db_update.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/db/db_update.php b/db/db_update.php index 3a6deb6..1a6f6f2 100644 --- a/db/db_update.php +++ b/db/db_update.php @@ -55,6 +55,15 @@ if($dbcodeversion && $dbdbversion) for($ver=$dbdbversion+1;$ver<=$dbcodeversion;$ver++) { + if(file_exists("db.update.$ver.php")) + { + include("db.update.$ver.php"); + } + if(is_callable("db_update_pre")) { + echo "db.update.$ver.php::db_update_pre() exists - running...\n"; + call_user_func("db_update_pre"); + echo "db.update.$ver.php::db_update_pre() done.\n"; + } if(file_exists("db.update.$ver.sql")) { echo "db.update.$ver.sql detected - running...\n"; @@ -64,7 +73,12 @@ if($dbcodeversion && $dbdbversion) } else { - echo "Version $ver update file not found - skipping over\n"; + echo "Version $ver SQL update file not found - skipping over\n"; + } + if(is_callable("db_update_post")) { + echo "db.update.$ver.php::db_update_post() exists - running...\n"; + call_user_func("db_update_post"); + echo "db.update.$ver.php::db_update_post() done.\n"; } } echo "\nAll done - updating new DB version to $dbcodeversion\n";