本文整理汇总了PHP中create_db函数的典型用法代码示例。如果您正苦于以下问题:PHP create_db函数的具体用法?PHP create_db怎么用?PHP create_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cos_reset_install
/**
* @deprecated not used anywhere
* wrapper function for reseting install to default one
* all data will be lost
*/
function cos_reset_install()
{
cos_rm_files();
drop_db_default();
create_db();
load_db_default();
cos_create_files();
cos_chmod_files();
cos_install();
}
示例2: get_db
function get_db()
{
$db_file_exists = file_exists(SQL_FILE_PATH);
$db = sqlite_open(SQL_FILE_PATH, 0666, $sqliteerror);
if (!$db) {
die($sqliteerror);
}
if (!$db_file_exists) {
create_db($db);
}
return $db;
}
示例3: connect_db
function connect_db($db_server, $db_username, $db_password, $db_name)
{
if (establish_connection($db_server, $db_username, $db_password)) {
$database = mysql_select_db($db_name);
if ($database) {
return 1;
} else {
create_db($db_name);
}
return 1;
} else {
die("Couldn't establish connection to database");
}
}
示例4: create_client
function create_client($subdomain, $client_name, $client_username, $client_email, $client_password)
{
if ($db = create_db($subdomain) !== false) {
try {
$con = new wpdb(MYSQL_ROUTING_USER, MYSQL_ROUTING_PASSWORD, MYSQL_ROUTING_DB, MYSQL_ROUTING_HOST);
$result = $con->insert('client', array('subdomain' => $subdomain, 'email' => $client_email, 'name' => $client_name, 'admin_username' => $client_username, 'admin_password' => base64_encode($client_password), 'status' => 0, 'db_driver' => 'mysql', 'db_host' => 'localhost', 'db_name' => $db["db_name"], 'db_user' => $db["db_user"], 'db_pass' => $db["db_pass"], 'db_charset' => 'utf8', 'db_collation' => 'utf8_unicode_ci', 'db_prefix' => '', 'created_at' => date("Y-m-d H:i:s")), array('%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'));
if ($result) {
return true;
}
} catch (Exception $e) {
return false;
}
}
return false;
}
示例5: ob_end_clean
ob_end_clean();
if (!$link) {
output("`\$Blast! I wasn't able to connect to the database server with the information you provided!");
output("`2This means that either the database server address, database username, or database password you provided were wrong, or else the database server isn't running.");
output("The specific error the database returned was:");
rawoutput("<blockquote>" . $error . "</blockquote>");
output("If you believe you provided the correct information, make sure that the database server is running (check documentation for how to determine this).");
output("Otherwise, you should return to the previous step, \"Database Info\" and double-check that the information provided there is accurate.");
$session['stagecompleted'] = 3;
} else {
output("`^Yahoo, I was able to connect to the database server!");
output("`2This means that the database server address, database username, and database password you provided were probably accurate, and that your database server is running and accepting connections.`n");
output("`nI'm now going to attempt to connect to the LoGD database you provided.`n");
if (httpget("op") == "trycreate") {
require_once 'lib/installer/installer_functions.php';
create_db($session['dbinfo']['DB_NAME']);
}
if (!db_select_db($session['dbinfo']['DB_NAME'])) {
output("`\$Rats! I was not able to connect to the database.");
$error = db_error();
if ($error == "Unknown database '{$session['dbinfo']['DB_NAME']}'") {
output("`2It looks like the database for LoGD hasn't been created yet.");
output("I can attempt to create it for you if you like, but in order for that to work, the account you provided has to have permissions to create a new database.");
output("If you're not sure what this means, it's safe to try to create this database, but you should double check that you've typed the name correctly by returning to the previous stage before you try it.`n");
output("`nTo try to create the database, <a href='installer.php?stage=4&op=trycreate'>click here</a>.`n", true);
} else {
output("`2This is probably because the username and password you provided doesn't have permission to connect to the database.`n");
}
output("`nThe exact error returned from the database server was:");
rawoutput("<blockquote>{$error}</blockquote>");
$session['stagecompleted'] = 3;
示例6: write_db
function write_db($stm, $table, $days)
{
global $postfix_dir, $config, $g;
conf_mount_rw();
$do_sync = array();
print "writing to database...";
foreach ($days as $day) {
if (strlen($stm[$day]) > 10 && is_array($config['installedpackages']['postfixsync']['config'])) {
foreach ($config['installedpackages']['postfixsync']['config'] as $rs) {
foreach ($rs['row'] as $sh) {
$sync_to_ip = $sh['ipaddress'];
$sync_type = $sh['sync_type'];
$password = $sh['password'];
$sql_file = '/var/db/postfix/' . $sync_to_ip . '.sql';
${$sync_to_ip} = "";
if (file_exists($sql_file)) {
${$sync_to_ip} = file_get_contents($sql_file);
}
if ($sync_to_ip && $sync_type == "share") {
${$sync_to_ip} .= serialize(array('day' => $day, 'sql' => base64_encode(gzcompress($stm[$day] . "COMMIT;", 9)))) . "\n";
if (!in_array($sync_to_ip, $do_sync)) {
$do_sync[] = $sync_to_ip;
}
}
}
}
/* Write local db file */
create_db($day . ".db");
if ($debug) {
print "writing to local db {$day}...";
}
$dbhandle = sqlite_open($postfix_dir . $day . ".db", 0666, $error);
if (!$dbhandle) {
die($error);
}
//file_put_contents("/tmp/" . $key . '-' . $update['day'] . ".sql", gzuncompress(base64_decode($update['sql'])), LOCK_EX);
$ok = sqlite_exec($dbhandle, $stm[$day] . "COMMIT;", $error);
if (!$ok) {
print "Cannot execute query. {$error}\n" . $stm[$day] . "COMMIT;\n";
} elseif ($debug) {
print "ok\n";
}
sqlite_close($dbhandle);
}
}
/* Write updated sql files */
if (count($do_sync) > 0) {
foreach ($do_sync as $ip) {
file_put_contents('/var/db/postfix/' . $ip . '.sql', ${$ip}, LOCK_EX);
}
}
conf_mount_ro();
/* Write local file */
}
示例7: define
define('DOING_UPGRADE', true);
require_once 'init.php';
require_once 'include/data_upgrade.php';
/* @var $db ADOConnection */
if (defined('CURRENT_SCHEMA') && (int) CURRENT_SCHEMA >= (int) REQUIRED_SCHEMA) {
?>
<html><head><title>Upgrade complete</title></head>
<body><h1>Upgrade Complete</h1><p>Scriptmind::Links database is at the same
version as the installed copy of the software.</p>
<p><a href="index.php">Return</a>
to to index.</p></body></html><?php
exit;
}
echo "Updating database schema<br/>\n";
flush();
$create = create_db(false);
if ($create[0]) {
echo "Result: Ok: " . $create[1] . "<br/><br/>\n\n";
} else {
echo "Result: Failed: " . $create[1] . " " . $create[2] . "<br/><br/>\n\n";
echo "Either fix the problem or restore the database and package software.<br/>\n";
exit;
}
if (!defined('CURRENT_SCHEMA')) {
define('CURRENT_SCHEMA', '0');
$template = $tables['config']['data'][0];
$row = array();
foreach ($template as $fld => $val) {
switch ($fld) {
case 'VALUE':
$row['VALUE'] = CURRENT_SCHEMA;
示例8: usersMenus
include_once 'ressources/class.influx.inc';
$users = new usersMenus();
if (!$users->AsWebStatisticsAdministrator) {
echo FATAL_ERROR_SHOW_128("{ERROR_NO_PRIVS}");
die;
}
if (isset($_GET["popup"])) {
table();
exit;
}
if (isset($_GET["search"])) {
search();
exit;
}
if (isset($_POST["new-db"])) {
create_db();
exit;
}
if (isset($_REQUEST["delete-db"])) {
delete_db();
exit;
}
if (isset($_GET["delete-db-js"])) {
delete_db_js();
exit;
}
js();
function js()
{
$t = time();
$page = CurrentPageName();
示例9: step_5
function step_5()
{
if (request_confirm('Start_Installation') || request_confirm('step') && request_get('step') === 3) {
$access = false;
if (request_confirm('Start_Installation')) {
if (create_db()) {
//install_bdd();
$access = true;
}
}
if (request_confirm('step') && request_get('step') === 3) {
$access = true;
}
if ($access) {
if (request_confirm('Start_Installation')) {
install_edit_step_record(3);
}
mmorpg_init();
// creatio des levels
?>
Installation de caranille terminée avec succès<br />
Dans la suite de l'installation vous allez devoir configurer les bases de votre MMORPG<br />
<form method="POST" action="<?php
echo get_link("Install") . "&step=4";
?>
">
<input type="submit" name="Configure" value="Configurer mon MMORPG"/>
</form>
<?php
}
}
}
示例10: config_done
/**
* 配置表单的处理脚本
*
* @author Garbin
* @return void
*/
function config_done()
{
$missing_items = array();
foreach ($_POST as $key => $value) {
if (empty($value) && $key != 'db_pass') {
$missing_items[] = $key;
}
}
if (!empty($missing_items)) {
$this->_doing = $this->_done;
$this->assign('missing_items', $missing_items);
$this->config();
return false;
}
extract($_POST);
if (!eregi('^http(s?)://', $site_url)) {
$this->_doing = $this->_done;
$this->assign('site_url_error', true);
$this->config();
return false;
}
if (!is_email($admin_email)) {
$this->_doing = $this->_done;
$this->assign('admin_email_error', true);
$this->config();
return false;
}
if ($admin_pass != $pass_confirm) {
$this->_doing = $this->_done;
$this->assign('pass_error', true);
$this->config();
return false;
}
/* 检查输入的数据库配置信息*/
/* 检查是否能连上数据库 */
$con = @mysql_connect($db_host . ':' . $db_port, $db_user, $db_pass);
if (!$con) {
$this->_doing = $this->_done;
$this->assign('mysql_error', mysql_error());
$this->config();
return false;
}
/* 检查数据库是否存在 */
$selected_db = @mysql_select_db($db_name);
if (!$selected_db) {
/* 如果不存在,尝试创建该数据库 */
$created_db = @create_db($db_name, $con);
/* 创建不成功,则显示错误 */
if (!$created_db) {
$this->_doing = $this->_done;
$this->assign('create_db_error', mysql_error());
$this->config();
return false;
}
} else {
/* 如果存在,检查是否已安装过ECMall */
$query = @mysql_query("SHOW TABLES LIKE '{$db_prefix}%'");
/* 如果安装过,检查是否同意强制安装 */
$has_ecmall = false;
while ($row = mysql_fetch_assoc($query)) {
$has_ecmall = true;
break;
}
/* 有ECMall,但不同意强制安装,则显示错误 */
if ($has_ecmall && empty($_POST['force_install'])) {
$this->_doing = $this->_done;
$this->assign('has_ecmall', true);
$this->config();
return false;
}
/* 没有装过ECMall或有ECMall但同意强制安装,则直接通过 */
}
return true;
}
示例11: foreach
foreach ($db->errors as $error) {
echo $error . '<br />';
}
echo '<p class="step"><a href="setup.php?step=1" class="button">Go Back</a></p>';
exit;
}
$c = new config();
$c->setFile('config.php');
$c->openFile();
$c->insert("mysql_db_name", $dbname);
$c->insert("mysql_db_user", $uname);
$c->insert("mysql_db_passwd", $pwd);
$c->insert("mysql_db_host", $dbhost);
$c->insert("table_prefix", $prefix);
$c->closeFile();
create_db($db, $prefix);
$db->close();
?>
<p>All right sparky! You've made it through this part of the
installation. Now the IPN recorder database has been created. If you are
ready, time now to…</p>
<p class="step"><a href="control.php" class="button">Go To Control Panel</a></p>
<?php
break;
}
function display_header($type = '')
{
switch ($type) {
default:
$title = "Setup Page";
示例12: experiments
/*$pdo->exec("create database my_db2"); //создаем базу данных
$pdo->exec("use my_db2"); // подключаемся к базе данных
$pdo->exec("create table experiments(id_exp INT not null prymary key, data INT, lastname CHAR)");//т.эксп.
$pdo->exec("create table bricks (id_exp INT, numb INT , score INT, fraction FLOAT)"); //создаем таблицу результатов
*/
} catch (PDOException $ex) {
die("Error: " . $ex->getMessage());
}
return $pdo;
}
/*---------------------------------------подключаемся к бд с пом. pdo------------------------------------------*/
try {
$pdo = new PDO("mysql:host=localhost;dbname=my_db2", "root");
} catch (PDOException $ex) {
if ($ex->getCode() == 1049) {
$pdo = create_db();
} else {
die("Error: " . $ex->getMessage());
}
}
if (isset($_GET['ln'])) {
$ln = $_GET['ln'];
}
if (isset($_GET['nexp'])) {
$nexp = $_GET['nexp'];
$exper = "<h3>{$nexp}</h3><table class='my_table'><tr><td>Кол-во<br>очков</td><td>Ск. раз<br>выпало</td><td>\n\tВ %<br>соотн-ии</td></tr><tr>";
//заг. табл.эксп-нтов
/*----------------------------выводим результаты для данного эксперимента--------------------------------------*/
$rez = $pdo->query('SELECT numb, score, fraction FROM bricks WHERE id_exp=' . $nexp . ' ORDER BY numb')->fetchAll(PDO::FETCH_ASSOC);
for ($i = 0; $i < count($rez); $i++) {
foreach ($rez[$i] as $key => $val) {
示例13: install_db
function install_db($db_details)
{
global $tpl;
if (!is_array($db_details) || empty($db_details)) {
$tpl->assign('form_error', _L('Could not process input data.'));
return 0;
}
$ret = update_config('config/config.php', array('LANGUAGE' => $db_details['language'], 'DB_DRIVER' => $db_details['db_driver'], 'DB_HOST' => $db_details['db_host'], 'DB_NAME' => $db_details['db_name'], 'DB_USER' => $db_details['db_user'], 'DB_PASSWORD' => $db_details['db_password']));
if ($ret !== true) {
$tpl->assign('form_error', $ret);
return 0;
}
$ret = create_db(true, $db_details['db_driver'], $db_details['db_host'], $db_details['db_name'], $db_details['db_user'], $db_details['db_password']);
if (!$ret[0]) {
// Database creation error
$tpl->assign('form_error', $ret[1]);
$tpl->assign('sql_error', $ret[2]);
return 0;
} else {
// Database was created/updated
$tpl->assign('message', $ret[1]);
return 1;
}
}
示例14: configure
//.........这里部分代码省略.........
$missing_site_admin_user = true;
} else {
if (!validate_db_name($site_admin_user)) {
$bad_site_admin_user = true;
}
}
if (empty($site_admin_password)) {
$missing_site_admin_password = true;
} else {
if (!validate_password($site_admin_password)) {
$weak_site_admin_password = true;
}
}
}
break;
default:
break;
}
switch ($action) {
case 'configure':
if ($bad_token or $bad_write_permission or $missing_sitename or $missing_webmaster or $missing_content_languages or $bad_default_language or $missing_db_admin_user or $missing_db_admin_password or $missing_db_name or $bad_db_name or $bad_db_type or $missing_db_host or $bad_db_host or $missing_db_user or $bad_db_user or $missing_db_password or $weak_db_password or $missing_site_admin_user or $bad_site_admin_user or $missing_site_admin_password or $weak_site_admin_password) {
break;
}
$site_admin_mail = $site_admin_user . '@' . $sitename;
$languages = array($default_language);
foreach ($content_languages as $clang) {
if ($clang != $default_language) {
$languages[] = $clang;
}
}
if ($db_flag) {
switch ($db_type) {
case 'pgsql':
require_once 'configurepgsql.php';
break;
case 'mysql':
default:
require_once 'configuremysql.php';
break;
}
if (!$db_reuse) {
try {
create_db($db_admin_user, $db_admin_password, 'localhost', $db_name, $db_user, $db_password);
} catch (PDOException $e) {
$db_error = $e->getMessage();
break;
}
}
try {
init_db($db_host, $db_name, $db_user, $db_password, $db_prefix, $site_admin_user, $site_admin_password, $site_admin_mail, $default_language);
} catch (PDOException $e) {
$db_error = $e->getMessage();
break;
}
$img = identicon($site_admin_user, AVATAR_SIZE);
@imagepng($img, AVATARS_DIR . DIRECTORY_SEPARATOR . $site_admin_user . '.png');
$db_inc = build_db_inc($db_host, $db_name, $db_user, $db_password, $db_prefix, $db_type);
$config_inc = build_config_inc($sitename, $webmaster, $site_admin_user, 1, 'home', 'page', $languages);
$features = array('captcha', 'avatar', 'rssfeed', 'home', 'contact', 'user', 'nobody', 'account', 'password', 'newuser', 'search', 'suggest', 'download', 'admin', 'adminuser', 'pagecontent', 'pagevisit', 'page', 'editpage', 'folder', 'folderedit', 'story', 'storyedit', 'book', 'bookedit', 'newsletter', 'newsletteredit', 'newslettersubscribe', 'newsletterunsubscribe', 'thread', 'threadedit', 'node', 'editnode', 'donation', 'paypalreturn', 'paypalcancel', 'sslverifyclient', 'saction');
$aliases_inc = build_aliases_inc($features, $languages);
} else {
$db_inc = build_db_inc(false, false, false, false, false, false);
$config_inc = build_config_inc($sitename, $webmaster, $site_admin_user, false, 'homepage', 'anypage', $languages);
$features = array('captcha', 'avatar', 'rssfeed', 'homepage', 'contact', 'donation', 'paypalreturn', 'paypalcancel', 'sslverifyclient', 'saction');
$aliases_inc = build_aliases_inc($features, $languages);
}
if (!$db_inc or !$config_inc or !$aliases_inc) {
$internal_error = true;
break;
}
if (!@file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . DB_INC, array('<?php', $db_inc))) {
$file_error = true;
break;
}
if (!@file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . CONFIG_INC, array('<?php', $config_inc))) {
$file_error = true;
break;
}
if (!@file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . ALIASES_INC, array("<?php", $aliases_inc))) {
$file_error = true;
break;
}
$sitemap_xml = build_sitemap_xml($sitename, $languages);
@file_put_contents(ROOT_DIR . DIRECTORY_SEPARATOR . SITEMAP_XML, array('<?xml version="1.0" encoding="UTF-8"?>', "\n", $sitemap_xml));
$robots_txt = build_robots_txt($sitename, $languages);
@file_put_contents(ROOT_DIR . DIRECTORY_SEPARATOR . ROBOTS_TXT, $robots_txt);
$logo = strlogo($sitename);
@imagepng($logo, LOGOS_DIR . DIRECTORY_SEPARATOR . SITELOGO_PNG, 9, PNG_ALL_FILTERS);
imagedestroy($logo);
session_reopen();
reload($base_url);
return false;
default:
break;
}
$_SESSION['configure_token'] = $token = token_id();
$errors = compact('bad_write_permission', 'missing_sitename', 'missing_webmaster', 'missing_content_languages', 'bad_default_language', 'missing_db_admin_user', 'missing_db_admin_password', 'bad_db_type', 'missing_db_name', 'bad_db_name', 'missing_db_host', 'bad_db_host', 'bad_db_prefix', 'missing_db_user', 'bad_db_user', 'missing_db_password', 'weak_db_password', 'missing_site_admin_user', 'bad_site_admin_user', 'missing_site_admin_password', 'weak_site_admin_password');
$output = view('configure', $lang, compact('token', 'sitename', 'webmaster', 'db_error', 'file_error', 'internal_error', 'content_languages', 'default_language', 'db_flag', 'db_type', 'db_reuse', 'db_admin_user', 'db_admin_password', 'db_name', 'db_host', 'db_prefix', 'db_user', 'db_password', 'site_admin_user', 'site_admin_password', 'errors'));
return $output;
}
示例15: cube
function cube()
{
define("Q", 36000);
$d = "";
$c2 = 0;
$c3 = 0;
$c4 = 0;
$c5 = 0;
$c6 = 0;
$c7 = 0;
$c8 = 0;
$c9 = 0;
$c10 = 0;
$c11 = 0;
$c12 = 0;
$d = [];
$e = [];
//$lastname=array("Симка","Нолик","Мася","Папус","Фаер","Верта","Игрек","Шпуля"); //массив экспериментаторов
$exp = rand(2, 5);
//кол-во экспериментов
$r = "<table class='my_table'><tr><td>№<br>эксп.</td><td>Кол-во<br>очков</td><td>Сколько раз<br>выпало</td><td>\n\t\tВ % соотн-ии</td></tr><tr>";
//заголовок таблицы результатов
$exper = "<table class='my_table'><tr><td>№<br>эксп.</td><td>Дата</td><td>Фамилия</td></tr><tr>";
//заг. табл.эксп-нтов
try {
$pdo = new PDO("mysql:host=localhost;dbname=my_db2", "root");
} catch (PDOException $ex) {
if ($ex->getCode() == 1049) {
$pdo = create_db();
} else {
die("Error: " . $ex->getMessage());
}
}
$pdo->exec("DROP TABLE experiments");
//удаляем таблицу экспериментов
$pdo->exec("DROP TABLE bricks");
//удаляем таблицу результатов
$pdo->exec("CREATE TABLE IF NOT EXISTS experiments (id_exp INT, data char(30), lastname CHAR(30))");
//создаем табл. экспериментов
$pdo->exec("CREATE TABLE IF NOT EXISTS bricks (id_exp INT, numb INT, score INT, fraction decimal(5,2))");
//созд.т.рез-тов
for ($j = 1; $j <= $exp; $j++) {
//эксперимент
$day = rand(1, 30);
if ($day < 10) {
$day = "0" . $day;
}
$month = rand(1, 12);
if ($month < 10) {
$month = "0" . $month;
}
$data = $day . "." . $month . ".15";
$ln = $lastname[rand(0, count($lastname) - 1)];
$pdo->prepare("INSERT INTO experiments (id_exp, data, lastname) VALUES(:id, :d, :ln)")->execute(array(':id' => $j, ':d' => $data, ':ln' => $ln));
for ($i = 0; $i < 36000; $i++) {
$c = rand(1, 6) + rand(1, 6);
switch ($c) {
case 2:
$d[2] = $c2++;
$e[2] = $c2 / Q * 100;
break;
case 3:
$d[3] = $c3++;
$e[3] = $c3 / Q * 100;
break;
case 4:
$d[4] = $c4++;
$e[4] = $c4 / Q * 100;
break;
case 5:
$d[5] = $c5++;
$e[5] = $c5 / Q * 100;
break;
case 6:
$d[6] = $c6++;
$e[6] = $c6 / Q * 100;
break;
case 7:
$d[7] = $c7++;
$e[7] = $c7 / Q * 100;
break;
case 8:
$d[8] = $c8++;
$e[8] = $c8 / Q * 100;
break;
case 9:
$d[9] = $c9++;
$e[9] = $c9 / Q * 100;
break;
case 10:
$d[10] = $c10++;
$e[10] = $c10 / Q * 100;
break;
case 11:
$d[11] = $c11++;
$e[11] = $c11 / Q * 100;
break;
case 12:
$d[12] = $c12++;
$e[12] = $c12 / Q * 100;
//.........这里部分代码省略.........