Location: PHPKode > scripts > MySQL Ajax Database Access Layer - MADAL > GenerateMVC.php
<?php
require_once 'DBStructure.php';

if (isset($argc) && $argc > 1) {
	$db = NULL;
	$db_host = 'localhost';
	$username = 'root';
	$password = '';

	for ($ii = 1; $ii < $argc; $ii++) {
		switch ($argv[$ii]) {
		case '-help':
		case '/?':
		case '--help':
			echo <<<EOD
Usage: {$argv[0]} [options] <dbname>
Options:
	--help : show this help message

	[-d  | --db]  <database> (default "$db")
	[-h  | --host] <host:port> (default "$db_host")
	[-u  | --username] <username> (default "$username")
	[-p  | --password] <password> (default "$password")
	[-np | --no-password]

EOD;
			exit();
		case '--host':
		case '--db_host':
		case '-h':
			$db_host = $argv[++$ii];
			break;
		case '--username':
		case '-u':
			$username = $argv[++$ii];
			break;
		case '-p':
		case '--password':
			$password = $argv[++$ii];
			break;
		case '-np':
		case '--no-password':
			$password = '';
			break;
		case '--db':
			$db = $argv[++$ii];
			break;
		default:
			$db = $argv[$ii];
		}
	}
} else {
	$args = array('db', 'db_host', 'username', 'password');
	foreach ($args as $arg) {
		if (isset($_GET[$arg])) {
			$$arg = $_GET[$arg];
		} else {
			$$arg = FALSE;
		}
	}
}

if ($db && $db_host && $username) {
	define ( "DB_NAME", $db ); //the database from which to generate the code
	define ( "DB_HOST", $db_host ); //the host of the db
	define ( "DB_USERNAME", $username ); //the username for the db
	define ( "DB_PASSWORD", $password ); //the password for the db
	
	$reader = new DBStructure ( );
	echo $reader->writeTablesToPHPAndJavascriptObjects ();
} else {
	?><form action="GenerateMVC.php" method="get">
	Database Name: <input type="text"
	name="db" id="db" value="your database here"
/><br />
	Database Host: <input type="text"
	name="db_host" id="db_host" value="localhost"
/><br />
	Database Username: <input type="text"
	name="username" id="username" value="root"
/><br />
	Database Password: <input type="password"
	name="password" id="password" value=""
/><br />
 <input type="submit" value="Generate MVC Framework" /></form>
<?php
}
?>
Return current item: MySQL Ajax Database Access Layer - MADAL