本文整理汇总了PHP中create_database函数的典型用法代码示例。如果您正苦于以下问题:PHP create_database函数的具体用法?PHP create_database怎么用?PHP create_database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_database函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql_main
function sql_main()
{
global $gbl, $sgbl, $login, $ghtml;
/*
self::$__fdb = mysql_connect($db_server, 'kloxo', getAdminPass());
mysql_select_db($sgbl->__var_dbf);
self::$__database = 'mysql';
*/
create_database();
create_general();
}
示例2: create_main
function create_main()
{
global $argc, $argv;
global $gbl, $sgbl, $login, $ghtml;
$opt = parse_opt($argv);
if (file_exists('/usr/local/lxlabs/.git')) {
$opt['development_found'] = '1';
}
lxfile_mkdir("{$sgbl->__path_program_etc}/conf");
lxfile_mkdir("{$sgbl->__path_program_root}/pid");
lxfile_mkdir("{$sgbl->__path_program_root}/log");
lxfile_mkdir("{$sgbl->__path_httpd_root}");
os_create_program_service();
if (isset($opt['admin-password'])) {
$admin_pass = $opt['admin-password'];
} else {
$admin_pass = 'admin';
}
if ($opt['install-type'] == 'master') {
if (!isset($opt['development_found'])) {
create_mysql_db('master', $opt, $admin_pass);
create_database();
create_general();
add_admin($admin_pass);
create_servername();
lxshell_return("__path_php_path", "../bin/collectquota.php");
} else {
print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n";
}
print "Updating the system. Will take a while\n";
system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=master");
} else {
if ($opt['install-type'] == 'slave') {
if (!isset($opt['development_found'])) {
init_slave($admin_pass);
} else {
print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n";
}
print "Updating the system. Will take a while\n";
system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=slave");
} else {
print "Unknown Install type\n";
flush();
}
}
system("rm -f /etc/sysconfig/network-scripts/ifcfg-*-range*");
//system("$sgbl->__path_php_path ../bin/misc/fixcentos5xen.php");
//os_fix_some_permissions();
system("cp ../sbin/lxxen ../sbin/lxopenvz /usr/bin");
system("chmod 4755 /usr/bin/lxxen /usr/bin/lxopenvz");
//os_set_iis_ftp_root_path();
}
示例3: create_main
function create_main()
{
global $argc, $argv;
global $gbl, $sgbl, $login, $ghtml;
$opt = parse_opt($argv);
lxfile_mkdir("{$sgbl->__path_program_etc}/conf");
lxfile_mkdir("{$sgbl->__path_program_root}/pid");
lxfile_mkdir("{$sgbl->__path_program_root}/log");
lxfile_mkdir("{$sgbl->__path_httpd_root}");
os_fix_lxlabs_permission();
os_create_program_service();
os_create_kloxo_service_once();
if (isset($opt['admin-password'])) {
$admin_pass = $opt['admin-password'];
} else {
$admin_pass = 'admin';
}
if ($opt['install-type'] == 'master') {
create_mysql_db('master', $opt, $admin_pass);
create_database();
create_general();
init_main($admin_pass);
lxshell_return("__path_php_path", "../bin/collectquota.php");
print "This will take a long time... Please wait...\n";
system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=master");
} else {
if ($opt['install-type'] == 'slave') {
init_slave($admin_pass);
print "This will take a long time... Please wait...\n";
system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=slave");
} else {
if ($opt['install-type'] == 'supernode') {
$sgbl->__path_sql_file = $sgbl->__path_sql_file_supernode;
$sgbl->__var_dbf = $sgbl->__path_supernode_db;
$sgbl->__path_admin_pass = $sgbl->__path_super_pass;
$sgbl->__var_admin_user = $sgbl->__var_super_user;
create_mysql_db('super', $opt, $admin_pass);
init_supernode($admin_pass);
print "\n";
} else {
print "Unknown Install type\n";
flush();
}
}
}
os_create_default_slave_driver_db();
os_fix_some_permissions();
}
示例4: isset
}
$db_host = isset($_POST['dbhost']) ? trim($_POST['dbhost']) : '';
$db_port = isset($_POST['db_port']) ? trim($_POST['db_port']) : '';
$db_user = isset($_POST['dbuser']) ? trim($_POST['dbuser']) : '';
$db_pass = isset($_POST['dbpass']) ? trim($_POST['dbpass']) : '';
$db_name = isset($_POST['dbname']) ? trim($_POST['dbname']) : '';
$prefix = isset($_POST['db_prefix']) ? trim($_POST['db_prefix']) : 'ecs_';
$timezone = isset($_POST['timezone']) ? trim($_POST['timezone']) : 'Asia/Shanghai';
if (empty($db_host) || empty($db_user) || empty($db_pass) || empty($db_name)) {
data_back('缺少必要的参数');
}
$result = create_config_file($db_host, $db_port, $db_user, $db_pass, $db_name, $prefix, $timezone);
if ($result === false) {
data_back('构建配置文件失败');
}
$result = create_database($db_host, $db_port, $db_user, $db_pass, $db_name);
if ($result === false) {
data_back('创建数据库失败');
}
$system_lang = isset($_POST['system_lang']) ? $_POST['system_lang'] : 'zh_cn';
if (file_exists(ROOT_PATH . 'install/data/data_' . $system_lang . '.sql')) {
$data_path = ROOT_PATH . 'install/data/data_' . $system_lang . '.sql';
} else {
$data_path = ROOT_PATH . 'install/data/data_zh_cn.sql';
}
$sql_files = array(ROOT_PATH . 'install/data/structure.sql', $data_path);
$result = install_data($sql_files);
if ($result === false) {
data_back('构建数据库内容失败');
}
$admin_name = isset($_POST['admin_name']) ? json_str_iconv(trim($_POST['admin_name'])) : 'admin';
示例5: queries_adminer_redirect
$_GET["db"] = "";
// to save in global history
queries_adminer_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
} elseif (DB !== $name) {
// create or rename database
if (DB != "") {
$_GET["db"] = $name;
queries_adminer_redirect(preg_replace('~\\bdb=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
} else {
$databases = explode("\n", str_replace("\r", "", $name));
$success = true;
$last = "";
foreach ($databases as $db) {
if (count($databases) == 1 || $db != "") {
// ignore empty lines but always try to create single database
if (!create_database($db, $row["collation"])) {
$success = false;
}
$last = $db;
}
}
queries_adminer_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
}
} else {
// alter database
if (!$row["collation"]) {
adminer_redirect(substr(ME, 0, -1));
}
query_adminer_redirect("ALTER DATABASE " . idf_escape($name) . (preg_match('~^[a-z0-9_]+$~i', $row["collation"]) ? " COLLATE {$row['collation']}" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
}
}
示例6: die
die("Connection failed");
}
query_check('DROP DATABASE irremote;');
}
function create_database()
{
global $db;
$db = new mysqli(DB_SERVER, DB_USER, DB_PASS);
if ($db->connect_error) {
die("Connect failed");
}
query_check('CREATE DATABASE IF NOT EXISTS ' . DB_NAME);
query_check('USE ' . DB_NAME);
query_check('CREATE TABLE IF NOT EXISTS users (' . 'id int NOT NULL AUTO_INCREMENT,' . 'email VARCHAR(255) NOT NULL,' . 'username VARCHAR(32) NOT NULL,' . 'password VARCHAR(128) NOT NULL,' . 'reg_date TIMESTAMP NOT NULL DEFAULT NOW(),' . 'access_token VARCHAR(32),' . 'PRIMARY KEY (id)' . ');');
query_check('ALTER TABLE users AUTO_INCREMENT=10000;');
query_check('CREATE TABLE IF NOT EXISTS registrations (' . 'username VARCHAR(32) NOT NULL,' . 'email VARCHAR(255) NOT NULL,' . 'password VARCHAR(128) NOT NULL,' . 'reg_date TIMESTAMP NOT NULL DEFAULT NOW(),' . 'token CHAR(32) NOT NULL' . ');');
query_check('CREATE TABLE IF NOT EXISTS remotes (' . 'id int NOT NULL AUTO_INCREMENT,' . 'parent_id int,' . 'user_id int,' . 'manufacturer VARCHAR(64),' . 'model VARCHAR(64),' . 'device_type VARCHAR(64),' . 'PRIMARY KEY (id),' . 'FOREIGN KEY (parent_id) REFERENCES remotes(id),' . 'FOREIGN KEY (user_id) REFERENCES users(id)' . ');');
query_check('ALTER TABLE remotes AUTO_INCREMENT=10000;');
query_check('CREATE TABLE IF NOT EXISTS buttons (' . 'remote_id int,' . 'function VARCHAR(64),' . 'frequency int,' . 'pattern VARCHAR(32768),' . 'FOREIGN KEY (remote_id) REFERENCES remotes(id)' . ');');
query_check('CREATE TABLE IF NOT EXISTS ratings (' . 'remote_id int NOT NULL,' . 'user_id int NOT NULL,' . 'rating tinyint,' . 'FOREIGN KEY (remote_id) REFERENCES remotes(id),' . 'FOREIGN KEY (user_id) REFERENCES users(id)' . ');');
echo '<br><br>All OK';
}
if ($allow_db_creation) {
if (isset($_GET['drop_db'])) {
drop_database();
}
if (isset($_GET['create_db'])) {
create_database();
}
echo '<!DOCTYPE html>' . '<html>' . '<body>' . ' <form mehtod="get" action="create-db.php">' . ' <input hidden name="create_db" value="true">' . ' <button type="submit">Create db</button>' . ' </form><br>' . ' <form mehtod="get" action="create-db.php">' . ' <input hidden name="drop_db" value="true">' . ' <button type="submit">Drop db</button>' . ' </form>' . '</body>' . '</html>';
}
示例7: install_step_3
function install_step_3()
{
$db_address = _request('db_address');
$db_login = _request('db_login');
$db_password = _request('db_password');
global $lcm_db_version;
$install_log = "";
$upgrade_log = "";
// Possible errors will get trapped in the output buffer and displayed later,
// so that they don't mess up with headers/html.
ob_start();
if (_request('db_choice') == "__manual__") {
$sel_db = _request('manual_db');
} else {
$sel_db = _request('db_choice');
}
$link = lcm_connect_db($db_address, 0, $db_login, $db_password, $sel_db);
$io_output = ob_get_contents();
ob_end_clean();
if (!$link) {
install_html_start('AUTO', '', 3);
lcm_panic("connection denied: " . lcm_sql_error());
}
//
// TEMPORARY (used by testing the installer)
/*
lcm_query("DROP TABLE lcm_case", true);
lcm_query("DROP TABLE lcm_case_attachment", true);
lcm_query("DROP TABLE lcm_stage", true);
lcm_query("DROP TABLE lcm_followup", true);
lcm_query("DROP TABLE lcm_author", true);
lcm_query("DROP TABLE lcm_client", true);
lcm_query("DROP TABLE lcm_client_attachment", true);
lcm_query("DROP TABLE lcm_org", true);
lcm_query("DROP TABLE lcm_org_attachment", true);
lcm_query("DROP TABLE lcm_contact", true);
lcm_query("DROP TABLE lcm_keyword", true);
lcm_query("DROP TABLE lcm_keyword_case", true);
lcm_query("DROP TABLE lcm_keyword_client", true);
lcm_query("DROP TABLE lcm_keyword_org", true);
lcm_query("DROP TABLE lcm_keyword_group", true);
lcm_query("DROP TABLE lcm_report", true);
lcm_query("DROP TABLE lcm_fields", true);
lcm_query("DROP TABLE lcm_filter", true);
lcm_query("DROP TABLE lcm_app", true);
lcm_query("DROP TABLE lcm_app_client_org", true);
lcm_query("DROP TABLE lcm_app_fu", true);
lcm_query("DROP TABLE lcm_author_app", true);
lcm_query("DROP TABLE lcm_case_client_org", true);
lcm_query("DROP TABLE lcm_case_author", true);
lcm_query("DROP TABLE lcm_client_org", true);
lcm_query("DROP TABLE lcm_rep_col", true);
lcm_query("DROP TABLE lcm_rep_line", true);
lcm_query("DROP TABLE lcm_rep_filters", true);
lcm_query("DROP TABLE lcm_filter_conds", true);
lcm_query("DROP TABLE lcm_rep_filter", true);
lcm_query("DROP TABLE lcm_meta", true);
*/
// Test if the software was already installed
$result = lcm_query("SELECT * FROM lcm_meta", true);
$already_installed = !lcm_sql_errno() && lcm_num_rows($result);
$old_lcm_version = 'NONE';
if ($already_installed) {
lcm_log("LCM already installed", 'install');
// Find the current database version
$old_lcm_db_version = 0;
$query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
$result = lcm_query_db($query);
while ($row = lcm_fetch_array($result)) {
$old_lcm_db_version = $row['value'];
}
lcm_log("LCM version installed is {$old_lcm_db_version}", 'install');
// Check if upgrade is needed
if ($old_lcm_db_version < $lcm_db_version) {
lcm_log("Calling the upgrade procedure (since < {$lcm_db_version})", 'install');
include_lcm('inc_db_upgrade');
$upgrade_log = upgrade_database($old_lcm_db_version);
} else {
lcm_log("Upgrade _not_ called, looks OK (= {$lcm_db_version})", 'install');
}
} else {
lcm_log("Creating the database from scratch", 'install');
include_lcm('inc_db_create');
$install_log .= create_database();
lcm_log("DB creation complete", 'install');
}
// Create default meta + keywords
include_lcm('inc_meta');
include_lcm('inc_keywords_default');
include_lcm('inc_meta_defaults');
init_default_config();
init_languages();
$skwg = get_default_keywords();
create_groups($skwg);
write_metas();
// regenerate inc/data/inc_meta_cache.php
// Test DB: not used for now..
include_lcm('inc_db_test');
$structure_ok = lcm_structure_test();
if (!empty($install_log)) {
//.........这里部分代码省略.........
示例8: trim
<?php
require 'create_db.php';
if (isset($_POST['hostname']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['database']) && !empty($_POST['hostname']) && !empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['database'])) {
$server = trim($_POST['hostname']);
$user = trim($_POST['username']);
$password = trim($_POST['password']);
$db = trim($_POST['database']);
create_database($server, $user, $password, $db);
$file = fopen($_SERVER['DOCUMENT_ROOT'] . "/connect.php", "w") or die("Unable to open file!");
$content = '<?php
error_reporting(0);
$connection = new mysqli("' . $server . '","' . $user . '","' . $password . '","' . $db . '");
if($connection->connect_errno) {
die("Sorry, we are having some problems!");
}
?>';
fwrite($file, $content);
fclose($file);
} else {
echo "All fields are mandatory!";
}
示例9: selectDb
/**
* 选择数据库
* @param string $dbName
* @return
*/
private function selectDb($dbName)
{
// 设置数据库字符集
mysql_query('SET NAMES "utf8"');
// 打开指定的数据库
if (!mysql_select_db($dbName, $this->conn)) {
// 指定数据库不存在,创建数据库
if (!create_database($dbName, $this->conn)) {
$this->closeDb();
// 没有权限创建数据库
$this->ajaxReturn(array('step' => 0, 'info' => '没有权限创建数据库!'));
}
if ($this->step == 0) {
$this->closeDb();
// 创建数据库成功
$data = array('step' => 1, 'info' => "成功创建数据库:{$dbName}<br>");
$this->ajaxReturn($data);
}
}
}
示例10: queries_redirect
$_GET["db"] = "";
// to save in global history
queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
} elseif (DB !== $name) {
// create or rename database
if (DB != "") {
$_GET["db"] = $name;
queries_redirect(preg_replace('~db=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $_POST["collation"]));
} else {
$databases = explode("\n", str_replace("\r", "", $name));
$success = true;
$last = "";
foreach ($databases as $db) {
if (count($databases) == 1 || $db != "") {
// ignore empty lines but always try to create single database
if (!create_database($db, $_POST["collation"])) {
$success = false;
}
$last = $db;
}
}
queries_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
}
} else {
// alter database
if (!$_POST["collation"]) {
redirect(substr(ME, 0, -1));
}
query_redirect("ALTER DATABASE " . idf_escape($name) . (eregi('^[a-z0-9_]+$', $_POST["collation"]) ? " COLLATE {$_POST['collation']}" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
}
}
示例11: test_input
<?php
include 'installUtil.php';
$dbhost = test_input($_POST['dbhost']);
$dbport = test_input($_POST['dbport']);
$dbname = test_input($_POST['dbname']);
$dbusername = test_input($_POST['dbusername']);
$dbpassword = test_input($_POST['dbpassword']);
$adminpassword = test_input($_POST['adminpassword']);
if ($dbport == null) {
$dbport = "3306";
}
if ($dbhost == null || $dbname == null || $dbusername == null || $adminpassword == null) {
header("Location: configure.php?error=param");
exit;
}
if (file_exists(__DIR__ . '/../../app/config/parameters.yml')) {
header("Location: configure.php?error=already");
exit;
}
//Testing mysql connection
$link = mysqli_connect($dbhost, $dbusername, $dbpassword, null, $dbport);
if (!$link) {
header("Location: configure.php?error=bdd");
exit;
}
create_database($link, $dbname);
import_dump($link, $dbname);
mysqli_close($link);
//Generating parameter.yml file
generateParameters($dbhost, $dbport, $dbname, $dbusername, $dbpassword, $adminpassword);
示例12: Database
}
if (isset($_POST['new_db'])) {
// new DB is to be created, approach depends on version of API
if (min_version("0.1.2-Beta-02")) {
// version is new enough to handle action by SQL
$db = new Database(ROOT_DATABASE);
$query = "CREATE DATABASE " . $_POST['new_db'];
if ($db->executeQuery($query)) {
$_GET['show'] = "database_details";
$_GET['db'] = $_POST['new_db'];
eval("\$gui_message .= \"" . gettemplate("message_db_created_sql") . "\";");
}
unset($db);
} else {
// version is too old, must fall back to system functions instead of SQL
if (create_database($_POST['new_db'])) {
$_GET['show'] = "database_details";
$_GET['db'] = $_POST['new_db'];
}
}
}
if (isset($_GET['delete_db'])) {
// DB is to be deleted, approach depends on version of API
if (isset($_POST['confirm'])) {
if ($_POST['confirm'] == "OK") {
if (min_version("0.1.2-Beta-02")) {
// version is new enough to handle action by SQL
$db = new Database(ROOT_DATABASE);
$query = "DROP DATABASE " . $_GET['delete_db'];
if ($db->executeQuery($query)) {
eval("\$gui_message .= \"" . gettemplate("message_db_deleted_sql") . "\";");
示例13: rename_database
/** Rename database from DB
* @param string new name
* @param string
* @return bool
*/
function rename_database($name, $collation)
{
$return = false;
if (create_database($name, $collation)) {
//! move triggers
$rename = array();
foreach (tables_list() as $table => $type) {
$rename[] = table($table) . " TO " . idf_escape($name) . "." . table($table);
}
$return = !$rename || queries("RENAME TABLE " . implode(", ", $rename));
if ($return) {
queries("DROP DATABASE " . idf_escape(DB));
}
restart_session();
set_session("dbs", null);
}
return $return;
}
示例14:
?>
<td class="error">MySQL Error - <?php
echo $sql_error['Text'];
?>
</td>
<?php
}
?>
</tr>
<?php
if ($sql_error['Code'] == 1049) {
?>
<tr>
<td>Create Database</td>
<?php
if (!($sql_error = create_database($db_name, $db_host, $db_username, $db_password))) {
?>
<td class="success">We were able to create the database - <?php
echo $db_name;
?>
</td>
<?php
$fail = FALSE;
?>
<?php
} else {
$fail = TRUE;
?>
<td class="error">MySQL Error - <?php
echo $sql_error['Text'];
示例15: int
# templates table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_EMAIL_STORAGE_DATABASE . ".`" . NQ_EMAIL_STORAGE_TABLE_PREFIX . "templates`\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Row ID in the table', \n\t\t\t\t\t\t\t`app_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'ID of the user who created the template', \n\t\t\t\t\t\t\t`environment` char(5) NOT NULL DEFAULT 'prod', \n\t\t\t\t\t\t\t`requires_unsubscribe` bit(1) NOT NULL DEFAULT b'1', \n\t\t\t\t\t\t\t`tag` char(25) NOT NULL, \n\t\t\t\t\t\t\t`subject` char(255) NOT NULL DEFAULT '' COMMENT 'The subject portion of the email', \n\t\t\t\t\t\t\t`body` text NOT NULL COMMENT 'The body of the email', \n\t\t\t\t\t\t\t`bcc` char(255) NOT NULL, \n\t\t\t\t\t\t\t`track` bit(1) NOT NULL DEFAULT b'1', \n\t\t\t\t\t\t\t`locked` bit(1) NOT NULL DEFAULT b'0', \n\t\t\t\t\t\t\t`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, \n\t\t\t\t\t\t\tPRIMARY KEY (`id`), \n\t\t\t\t\t\t\tUNIQUE KEY `app_tag` (`app_id`, `environment`, `tag`), \n\t\t\t\t\t\t\tKEY `app_name` (`app_id`, `environment`)\n\t\t\t\t\t\t)\n\t\t\t\t\tENGINE = InnoDB DEFAULT CHARSET = latin1;";
create_table($G_FILE_STORAGE_DBLINK, $query, $G_OUTPUT_RESULTS);
# templates_archived table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_EMAIL_STORAGE_DATABASE . ".`" . NQ_EMAIL_STORAGE_TABLE_PREFIX . "templates_archived`\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Row ID in the table', \n\t\t\t\t\t\t\t`app_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'ID of the user who created the template', \n\t\t\t\t\t\t\t`environment` char(5) NOT NULL, \n\t\t\t\t\t\t\t`requires_unsubscribe` bit(1) NOT NULL DEFAULT b'1', \n\t\t\t\t\t\t\t`tag` char(25) NOT NULL, \n\t\t\t\t\t\t\t`subject` char(255) NOT NULL DEFAULT '' COMMENT 'The subject portion of the email', \n\t\t\t\t\t\t\t`body` text NOT NULL COMMENT 'The body of the email', \n\t\t\t\t\t\t\t`bcc` char(255) NOT NULL, \n\t\t\t\t\t\t\t`track` bit(1) NOT NULL DEFAULT b'1', \n\t\t\t\t\t\t\t`locked` bit(1) NOT NULL DEFAULT b'0', \n\t\t\t\t\t\t\t`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, \n\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t)\n\t\t\t\t\tENGINE = InnoDB DEFAULT CHARSET = latin1;";
create_table($G_FILE_STORAGE_DBLINK, $query, $G_OUTPUT_RESULTS);
}
/* ----- End Email Tables ----- */
/* ----- Start Tracking Tables ----- */
# If we are going to install the tracking tables
if (INSTALL_TABLES && isset($_POST['tracking_mysql_install']) && $_POST['tracking_mysql_install'] != '') {
# Controller tracking header
create_header('Controller Tracking Database', $G_OUTPUT_RESULTS);
# Tracking Storage database
$query = "CREATE DATABASE IF NOT EXISTS " . NQ_TRACKING_DATABASE;
create_database($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);
# analytics_database_table_io table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_TRACKING_DATABASE . ".`" . NQ_TRACKING_TABLE_PREFIX . "analytics_database_table_io`\n\t\t\t\t\t\t(\n\t\t \t\t\t\t\t`app_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`environment` enum( '*', 'prod', 'beta', 'alpha', 'dev' ) NOT NULL, \n\t\t \t\t\t\t\t`table_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`reads` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`read_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`writes` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`write_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`deletes` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`delete_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`created` datetime NOT NULL, \n\t\t \t\t\t\t\tKEY `table_environment_created` ( `table_id`, `environment`, `created` )\n\t\t \t\t\t\t)\n\t\t\t\t\tENGINE = MEMORY DEFAULT CHARSET = latin1;";
create_table($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);
# analytics_database_table_io_summary table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_TRACKING_DATABASE . ".`" . NQ_TRACKING_TABLE_PREFIX . "analytics_database_table_io_summary`\n\t\t\t\t\t\t(\n\t\t \t\t\t\t\t`app_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`environment` enum( '*', 'prod', 'beta', 'alpha', 'dev' ) NOT NULL, \n\t\t \t\t\t\t\t`table_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`reads` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`read_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`writes` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`write_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`deletes` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`delete_rows` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`created` datetime NOT NULL, \n\t\t \t\t\t\t\tKEY `app_id` ( `app_id`, `table_id`, `created`, `environment` )\n\t\t \t\t\t\t)\n\t\t\t\t\tENGINE = InnoDB DEFAULT CHARSET = latin1;";
create_table($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);
# analytics_eails_blocked table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_TRACKING_DATABASE . ".`" . NQ_TRACKING_TABLE_PREFIX . "analytics_emails_blocked`\n\t\t\t\t\t\t(\n\t\t \t\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT, \n\t\t \t\t\t\t\t`app_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`template_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`sender` char(75) NOT NULL, \n\t\t \t\t\t\t\t`recipient` char(75) NOT NULL, \n\t\t \t\t\t\t\t`created` datetime NOT NULL, \n\t\t \t\t\t\t\tPRIMARY KEY (`id`)\n\t\t \t\t\t\t)\n\t\t\t\t\tENGINE = InnoDB DEFAULT CHARSET = latin1;";
create_table($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);
# analytics_email_sent table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_TRACKING_DATABASE . ".`" . NQ_TRACKING_TABLE_PREFIX . "analytics_emails_sent`\n\t\t\t\t\t\t(\n\t\t \t\t\t\t\t`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, \n\t\t \t\t\t\t\t`hash_id` char(64) NOT NULL, \n\t\t \t\t\t\t\t`app_id` int(10) unsigned NOT NULL DEFAULT '0', \n\t\t \t\t\t\t\t`template_id` int(10) unsigned NOT NULL DEFAULT '0', \n\t\t \t\t\t\t\t`sender` char(75) NOT NULL DEFAULT '', \n\t\t \t\t\t\t\t`recipient` char(75) NOT NULL DEFAULT '', \n\t\t \t\t\t\t\t`requested_date` datetime NOT NULL, \n\t\t \t\t\t\t\t`sent_date` datetime NOT NULL, \n\t\t \t\t\t\t\t`read` bit(1) NOT NULL, \n\t\t \t\t\t\t\t`read_date` datetime NOT NULL, \n\t\t \t\t\t\t\t`created` datetime NOT NULL, \n\t\t \t\t\t\t\tPRIMARY KEY (`id`), \n\t\t \t\t\t\t\tKEY `app_created_sender` (`app_id`, `created`, `sender`), \n\t\t \t\t\t\t\tKEY `hash_id` (`hash_id`)\n\t\t\t\t\t\t)\n\t\t\t\t\tENGINE = InnoDBDEFAULT CHARSET = latin1;";
create_table($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);
# api_calls_database table
$query = "\tCREATE TABLE IF NOT EXISTS " . NQ_TRACKING_DATABASE . ".`" . NQ_TRACKING_TABLE_PREFIX . "api_calls_database`\n\t\t\t\t\t\t(\n\t\t \t\t\t\t\t`app_id` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`environment` char(5) NOT NULL, \n\t\t \t\t\t\t\t`endpoint` enum( 'fetch', 'insert', 'update', 'delete', 'replicate', 'tables', 'structure', 'table', 'privilages', 'indices', 'update_primary', 'tables_diff' ) NOT NULL, \n\t\t \t\t\t\t\t`receive_size` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`send_size` int(10) unsigned NOT NULL, \n\t\t \t\t\t\t\t`send_time` float unsigned NOT NULL, \n\t\t \t\t\t\t\t`complete_time` float unsigned NOT NULL, \n\t\t \t\t\t\t\t`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, \n\t\t \t\t\t\t\tKEY `app_type_created` ( `app_id`, `created`, `environment` )\n\t\t \t\t\t\t)\n\t\t \t\t\tENGINE = InnoDB DEFAULT CHARSET = latin1;";
create_table($G_TRACKING_DBLINK, $query, $G_OUTPUT_RESULTS);