A PHP-related issue. Make an upgrade program

Source: Internet
Author: User
Ask for a PHP question. Make an upgrade program

I want to do an upgrade program for the website
I thought of a simple upgrade method. But do not know how to achieve. Special come to help

index.php is the upgrade file
There are still a lot of SQL files in the directory.
For example: 1.sql 2.sql 3.sql 4.sql 5.sql

So. For example, this version of the site is 2

Then when executing the index.php file in the browser: Automatically load or import 2.sql files. After the 2.sql import is successful. Automatic execution of SQL files larger than 2
Then the automatic down execution of 3.sql 4.sql 5.sql until after the completion of 5.sql is not bigger than the 5.sql system prompts for upgrade success

Don't know how to do this?

PS upgrade file is not necessarily 12345 20140101.sql 20140202.sql 20140303.sql

In short, judgment is bigger than itself. If there is bigger than itself, proceed without stopping.

I beg you to teach me how to achieve this.

Thank you
------to solve the idea----------------------
Is the version of the website written in the database?


$sqlfile = Array (
' 1 ' = ' 1.sql ',
' 2 ' = ' 2.sql ',
' 3 ' = ' 3.sql ',
' 4 ' = ' 4.sql ',
' 5 ' = ' 5.sql ',
);

while (1) {
Get Current version
$version = mysql_query ("Select version from version");

if ($version >=count ($sqlfile)) {
Break
}else{
$sql = $sqlfile [$version +1];
Read the SQL file and execute
echo ' Update '. ($version + 1). ' Success ';
}
}

echo ' Update complete ';
?>
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.