Web page installer - database deployment
A simple way would be to store the SQL queries in PHP files and have PHP inject the prefix into the SQL and return the string.
Like, if you had a PHP file like this for each of your CREATE TABLE queries:
<?php
/** get_myTable.php **/
return <<<SQL
CREATE TABLE `{$prefix}myTable` ( ... )
SQL;
?>
You could do this in your main code:
<?php
$prefix = 'dbprefix_';
$create_queries = array();
$create_queries[] = include('get_myTable.php');
$create_queries[] = include('get_otherTable.php');
foreach($create_queries as $_query) {
mysql_query($_query) or trigger_error(mysql_error(), E_USER_WARNING);
}
?>
Create an exe Installer for a website Wamp
Investigate the WIX Installer. http://wixtoolset.org/ It's a good start creating complex MSI\EXE setup packages and install wizards on Windows that can also install other applications and files as part of your package.
What you describe seems like it would fit within WIX.
PHP Installer Script
I've made my own installer script and here are my tips.
- Make sure to validate that the script will run (file & db permissions)
- Make sure the folders/files/db structure isn't already present (if the script has run before)
- If that's the case, make sure to have an option to remove these files
- Always keep in mind that the user/script can fail everywhere and it should always be possible to start over
Related Topics
PHP Variable Inside Echo 'HTML Code'
Authenticating in PHP Using Ldap Through Active Directory
How to Add a Line Break Within Echo in PHP
Manipulate a Url String by Adding Get Parameters
PHP 5.4 - 'Closure $This Support'
How to Convert Word Smart Quotes and Em Dashes in a String
PHP How to Import All Classes from Another Namespace
Tcpdf Utf-8 Symbols Not Showing Up
C#'s Null Coalescing Operator () in PHP
Utf-8 Character Encoding Battles JSON_Encode()
PHP What Is the Best Approach to Using Xml? Need to Create and Parse Xml Responses
How to Define an Empty Object in PHP
Access Post Values in Symfony2 Request Object
Symfony 2 Entitymanager Injection in Service
Woocommerce:Add Custom Metabox to Admin Order Page
How to Force PHP to Use Strings for Array Keys
How to Generate an Excel Document with Multiple Worksheets from PHP