本文整理汇总了PHP中createDB函数的典型用法代码示例。如果您正苦于以下问题:PHP createDB函数的具体用法?PHP createDB怎么用?PHP createDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createDB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wrconf
function wrconf()
{
$Host = $_REQUEST['host'];
$User = $_REQUEST['username'];
$Pass = $_REQUEST['password'];
$Name = $_REQUEST['nama'];
createDB($Host, $User, $Pass, $Name);
// Buka template
$tpl = "./install/connectdb.php.txt";
if (file_exists($tpl)) {
$ft = fopen($tpl, 'r');
$tpldb = fread($ft, filesize($tpl));
fclose($ft);
// Buka file konfigurasi
$file = "./config/connectdb.php";
$f = fopen($file, "w");
$_t = $tpldb . chr(12);
$_t = str_replace('~Host~', $Host, $_t);
$_t = str_replace('~User~', $User, $_t);
$_t = str_replace('~Pass~', $Pass, $_t);
$_t = str_replace('~Name~', $Name, $_t);
// tulis
fwrite($f, $_t);
fclose($f);
Berhasil($User, $Pass, $Host, $Name);
} else {
echo "failed";
}
}
示例2: importDB
function importDB($connection, $name, $file, $dbs)
{
// initialize
$returnValue = "";
$sql = "";
if (!in_array($name, $dbs)) {
createDB($connection, $name);
}
mysql_select_db($name, $connection);
// start reading in the file, if it exists
$lines = file($file);
foreach ($lines as $line) {
if (strlen($line) > 1) {
// to avoid blank lines
$sql .= ltrim(rtrim($line));
// if we've found a semi-colon it's time to execute
if (strpos($sql, ";")) {
if (!mysql_query($sql, $connection)) {
// rule out DROP calls to nonexistant tables
$error = mysql_error();
if (!stristr($error, "Unknown table")) {
$returnValue .= $error;
}
}
$sql = "";
}
}
}
// return any errors encountered
if ($returnValue) {
return 'Error importing database: ' . $returnValue;
}
}
示例3: connectAndSelectDB
function connectAndSelectDB()
{
// Gets the DB config
global $dbName, $dbServer, $dbUser, $dbPassword;
// Connects to the DB server
mysql_connect($dbServer, $dbUser, $dbPassword);
// Selects the relevant DB
if (!mysql_select_db($dbName)) {
if (mysql_errno() == 1049) {
// Selection failed because the DB does not exist
// Calls the createDB function
createDB();
} else {
// Selection failed because of other error
echo "Could not select DB";
}
}
}
示例4: init
function init()
{
createDB();
createTable_USER();
}
示例5: isset
$saldo = isset($data->saldo) ? $data->saldo : "0";
$observacoes = isset($data->observacoes) ? $data->observacoes : "0";
$link = createDB();
$sql = "UPDATE trabalho SET crianca_id = " . $crianca_id . ", valor = " . $valor . ", parcelas = " . $parcelas . ", saldo = " . $saldo . ", observacoes = '" . $observacoes . "' WHERE id = " . $idTrabalho . ";";
$result = mysql_query($sql, $link);
if (mysql_errno($link) > 0) {
echo json_encode(array("erro" => true, "mysql_errno" => mysql_errno($link), "mysql_error" => mysql_error($link), "sql" => $sql));
} else {
if ($result) {
echo json_encode(array("erro" => false));
}
}
mysql_close($link);
});
// Delete
$app->get('/excluirTrabalho/:idTrabalho', 'auth', function ($idTrabalho) use($app) {
$idTrabalho = (int) $idTrabalho;
$link = createDB();
$sql = "DELETE FROM Trabalho WHERE id = " . $idTrabalho . ";";
$result = mysql_query($sql, $link);
if (mysql_errno($link) > 0) {
echo json_encode(array("erro" => true, "mysql_errno" => mysql_errno($link), "mysql_error" => mysql_error($link), "sql" => $sql));
} else {
if ($result) {
echo json_encode(array("erro" => false));
}
}
mysql_close($link);
});
// fim Crud Trabalho
$app->run();
示例6: createDB
<?php
include_once '../arc/ARC2.php';
$DEBUG = false;
if (isset($_GET['cmd'])) {
$cmd = $_GET['cmd'];
if ($cmd == "create-db") {
echo createDB();
} else {
if ($cmd == "create-store") {
createStore();
} else {
echo "<p>Sorry, I didn't understand the command ...</p>";
}
}
}
function createDB()
{
global $DEBUG;
$host = urldecode($_GET['host']);
$name = $_GET['name'];
$user = $_GET['user'];
$pwd = $_GET['pwd'];
$ret = "<p>";
$dbExists = false;
$con = mysql_connect($host, $user, $pwd);
// try to connect
if (!$con) {
die('Could not connect: ' . mysql_error());
}
$dblist = mysql_list_dbs($con);
示例7: fopen
$Content .= "Server : " . $_SERVER['SERVER_SOFTWARE'] . "\n";
$Content .= "Admin : " . $_SERVER['SERVER_ADMIN'] . "\n\n";
$Content .= "Document Root : " . $_SERVER['DOCUMENT_ROOT'] . "\n";
$Content .= "ROOT_PATH : " . ROOT_PATH . "\n\n";
$Content .= "OrangeHRM Installation Log\n\n";
$filename = 'installer/log.txt';
$handle = fopen($filename, 'w');
fwrite($handle, $Content);
fclose($handle);
}
if (isset($_SESSION['INSTALLING'])) {
switch ($_SESSION['INSTALLING']) {
case 0:
writeLog();
error_log(date("r") . " DB Creation - Starting\n", 3, "installer/log.txt");
createDB();
error_log(date("r") . " DB Creation - Done\n", 3, "installer/log.txt");
if (!isset($error) || !isset($_SESSION['error'])) {
$_SESSION['INSTALLING'] = 1;
error_log(date("r") . " DB Creation - No Errors\n", 3, "installer/log.txt");
} else {
error_log(date("r") . " DB Creation - Errors\n", 3, "installer/log.txt");
error_log(date("r") . " " . (isset($error) ? $error : $_SESSION['error']) . "\n", 3, "installer/log.txt");
}
break;
case 1:
error_log(date("r") . " Fill Data Phase 1 - Starting\n", 3, "installer/log.txt");
fillData();
error_log(date("r") . " Fill Data Phase 1 - Done\n", 3, "installer/log.txt");
if (!isset($error) || !isset($_SESSION['error'])) {
$_SESSION['INSTALLING'] = 2;
示例8: gaasInitServer_server
function gaasInitServer_server($msg)
{
global $initState, $backEnd;
error_log("Init server called\n");
// here we "init" the server, if we're ad, we attempt to connect to AD and if it all works
// we then create the db
// $m["backend"] = "AD|IN";
// AD expects:
// $m["domain"] = "somedomain.com";
// $m["user"] = "someuser";
// $m["pass"] = "somepassword";
// $m["userdef"] = "user definition paramaters";
// IN expects
// $m["user"] = "someuser";
// $m["pass"] = "somepass";
echo "initstate is {$initState}";
if ($initState) {
echo "true\n";
} else {
echo "false\n";
}
if ($initState) {
error_log("init server called when server already init'd\n");
return false;
}
if ($msg["backend"] == "AD") {
$backEnd = "AD";
// attempt connect to AD, verify creds
$addom = $msg["domain"];
$adlogin = $msg["user"];
$adpass = $msg["pass"];
$adclientdef = $msg["clientdef"];
$adadmindef = $msg["admindef"];
// now wee test our logins...
// first look up the domain name stuff
$servers = dns_get_record("_gc._tcp.{$addom}");
if (count($servers) < 1) {
echo "AD servers cant be found, fail!\n";
}
// we should check all servers, but lets just go with 0 for now
$res = adTestLogin($addom, $adlogin, $adpass);
if (!$res) {
return false;
}
// then
createDB();
confSetVal("ad.domain", $addom);
confSetVal("ad.user", $adlogin);
confSetVal("ad.pass", $adpass);
confSetVal("ad.encryptionkey", generateHexString(32));
confSetVal("ad.clientdef", $adclientdef);
confSetVal("ad.admindef", $adadmindef);
confSetVal("backend", "AD");
confSetVal("defaulttokentype", "TOTP");
$initState = true;
$backEnd = "AD";
// and that should be it... i think cept im in a forked erg.. lets assume it works, need pain i do not.
return true;
} else {
if ($msg["backend"] == "IN") {
// this ones simpler
$backEnd = "IN";
createDB();
// create the user in the db
$username = $msg["user"];
$password = $msg["pass"];
$myga = new gaasdGA();
$myga->setUser($username);
if ($password == "") {
$pass = "";
} else {
$pass = hash('sha512', $password);
}
$db = getDB();
$db->query($sql = "update users set users_password='{$pass}' where users_username='{$username}'");
$initState = "running";
return true;
} else {
return false;
}
}
}
示例9: isset
$dbprefix = isset($_POST['dbprefix']) ? $_POST['dbprefix'] : '';
$language = isset($_POST['language']) ? $_POST['language'] : 'zh_cn';
$accept = isset($_POST['accept']) ? true : false;
if (!$accept) {
$result = -1;
$target = 'alert';
$info = t('bugfree', 'don\'t accept the license');
} else {
list($result, $info, $target, $con) = getDBCon($dbhost, $port, $dbuser, $dbpwd);
// db con check
if (!$result) {
list($result, $info, $target) = checkDB($con, $dbname, $dbprefix);
// db check
if (0 == $result || 1 == $result) {
if (setDBConfig($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix, $language, CONFIG_SAMPLE_FILE, CONFIG_FILE)) {
list($result, $info, $target) = createDB($con, $dbname, $result, $dbprefix);
if (!$result) {
file_put_contents('install.lock', '');
}
}
} else {
if (2 == $result) {
setDBConfig($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix, $language, CONFIG_SAMPLE_FILE, CONFIG_FILE);
}
}
@mysql_close($con);
}
}
echo json_encode(array('result' => $result, 'info' => $info, 'target' => $target));
break;
case INSTALLED:
示例10:
require_once '../bin/app.inc';
require_once 'util.php';
require_once 'siremisutil.php';
$isInstalled = false;
if (is_file(dirname(dirname(__FILE__)) . '/install.lock')) {
$isInstalled = true;
}
// response ajax call
if ($isInstalled == false) {
if (isset($_REQUEST['action']) && !$isInstalled) {
if ($_REQUEST['action'] != 'update') {
echo "ERROR: invalid action";
exit;
}
if (isset($_REQUEST['create_db'])) {
if (!createDB()) {
echo 'ERROR: Database ' . $_REQUEST['dbName'] . ' was not created';
exit;
}
}
if (isset($_REQUEST['load_db'])) {
if (!fillDB()) {
echo 'ERROR: Data was not populated into database.';
exit;
}
}
if (isset($_REQUEST['loadsip_db'])) {
if (!siremisFillDB()) {
echo 'ERROR: Data was not populated into SIP database.';
exit;
}
示例11: header
header("Content-type: text/txt; charset=utf-8");
//数据库的信息
$key = 666666;
$servername = "";
$username = "root";
$password = "";
$con = mysql_connect($servername, $username, $password);
if (!$con) {
die("无法连接Mysql数据库: " . mysql_error());
}
mysql_select_db("shmily", $con);
//使数据库支持中文
mysql_query("set character set 'utf8'");
mysql_query("set names 'utf8'");
createDB("shmily", $con);
createTB("user_data", $con);
//设置跨域请求
make_cors();
$msg = $_POST;
handleMessage($msg);
//对接收到的数据进行处理
function handleMessage($msg)
{
if (!$msg) {
return;
}
$Opt = $msg['operation'];
$data = $msg;
$Response = array();
switch ($Opt) {
示例12: createDB
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include "tableToImport.php";
include "createDB.php";
include "createDBTable.php";
createDB($serverName, $userName, $password, $DBName);
$tableN = count($tableToAdd);
for ($i = 0; $i < $tableN; ++$i) {
createDBTable($serverName, $userName, $password, $DBName, $tableToAdd[$i]);
}
// createDBTable($serverName, $userName, $password, $DBName, $tableToAdd[0]);
// createDBTable($serverName, $userName, $password, $DBName, $tableToAdd[1]);
示例13: updateDB
function updateDB($dbHost, $dbAdminUsername, $dbAdminPasswd, $dbName, $dbHostOld, $dbAdminUsernameOld, $dbAdminPasswdOld, $dbNameOld)
{
$version = explode(".", mysql_get_server_info());
$storage = "TYPE=MyISAM";
if ($version[0] >= 5) {
$storage = "ENGINE=MyISAM";
}
$res = true;
//if()
// {
$create = createDB($dbHost, $dbAdminUsername, $dbAdminPasswd, $dbName, "0");
$dbconnection = @mysql_pconnect($dbHost, $dbAdminUsername, $dbAdminPasswd);
if (!$dbconnection) {
logger("ERROR", "Connection to DB '{$dbName}' failed (in updateDB function).");
}
//start users table update
$dbconnectionOld = @mysql_connect($dbHostOld, $dbAdminUsernameOld, $dbAdminPasswdOld);
if (!$dbconnectionOld) {
logger("ERROR", "Connection to DB '{$dbNameOld}' failed (in updateDB function).");
$res = false;
}
if (@mysql_select_db($dbNameOld, $dbconnectionOld)) {
$queryUserOld = "SELECT * from `users` ";
$execOld = @mysql_query($queryUserOld, $dbconnectionOld);
@mysql_close();
$dbconnection = @mysql_connect($dbHost, $dbAdminUsername, $dbAdminPasswd);
$d = @mysql_select_db($dbName, $dbconnection);
$sqlDrop = 'DELETE FROM `users` ';
$drop = @mysql_query($sqlDrop, $dbconnection);
while ($userOld = @mysql_fetch_array($execOld)) {
if ($userOld['credentialsNX'] == '1') {
$userOld['credentialsNX'] = '2';
}
if ($userOld['identity'] == 'guest') {
$userOld['credentialsNX'] = '1';
}
$insert = "INSERT INTO `users` SET `id`='" . $userOld['id'] . "', `userName`='" . $userOld['userName'] . "', `password`='" . $userOld['password'] . "', `identity`='" . $userOld['identity'] . "', `credentialsNX`='" . $userOld['credentialsNX'] . "' ";
$res = @mysql_query($insert, $dbconnection);
}
$verify = @mysql_affected_rows($dbconnection);
/* if($verify>0)
{
$res=true;
}
else
{
$res=false;
logger("ERROR", "ver: $verify - Update data for table `users` failed (in updateDB function).");
} */
if ($res) {
//start servers table update
$dbconnectionOld = @mysql_connect($dbHostOld, $dbAdminUsernameOld, $dbAdminPasswdOld);
if (@mysql_select_db($dbNameOld, $dbconnectionOld)) {
$queryServerOld = "SELECT * from `servers` ";
$execOld = @mysql_query($queryServerOld, $dbconnectionOld);
@mysql_close();
}
$dbconnection = @mysql_connect($dbHost, $dbAdminUsername, $dbAdminPasswd);
$d = @mysql_select_db($dbName, $dbconnection);
//
// Table structure for table `servers`
//
//$sql=' DROP TABLE IF EXISTS `servers` ';
//$res=@mysql_query($sql, $dbconnection);
$sql = " \n CREATE TABLE IF NOT EXISTS `serversTmp` (\n `id` int(10) NOT NULL auto_increment,\n `serverName` varchar(200) NOT NULL default '',\n `hostName` varchar(200) NOT NULL default '',\n `port` varchar(50) NOT NULL default '',\n `CPU` varchar(100) NOT NULL default '',\n `memory` varchar(100) NOT NULL default '',\n `disk` varchar(100) NOT NULL default '',\n `OS` varchar(100) NOT NULL default '',\n `description` varchar(200) NOT NULL default '',\n `icon` varchar(100) NOT NULL default '',\n `displayMode` varchar(16) NOT NULL default '',\n `replacingText` varchar(200) NOT NULL default '',\n `defaultLink` varchar(6) NOT NULL default '',\n `displayLink` int(1) NOT NULL default '0', \n PRIMARY KEY (`id`)\n ) {$storage}\n ";
$res = @mysql_query($sql, $dbconnection);
$verify = @mysql_affected_rows($dbconnection);
if (!$res) {
logger("ERROR", "Create Table 'serversTmp' failed (in UpdateDB function).");
}
// $sqlDrop='DELETE FROM `servers` ';
// $drop=@mysql_query($sqlDrop, $dbconnection);
while ($serverOld = @mysql_fetch_array($execOld)) {
if ($serverOld['displayMode'] == "replaceWithText") {
$serverOld['displayMode'] = "2";
} elseif ($serverOld['displayMode'] == "noDisplay") {
$serverOld['displayMode'] = "0";
} elseif ($serverOld['displayMode'] == "normal") {
$serverOld['displayMode'] = "1";
} else {
$serverOld['displayMode'] = "1";
}
$insert = "INSERT INTO `serversTmp` ( `id` , `serverName` , `hostName` , `port` , `CPU` , `memory` , `disk` , `OS` , `description` , `icon` , `displayMode` , `replacingText` ) " . " VALUES ('" . $serverOld['id'] . "', '" . $serverOld['serverName'] . "', '" . $serverOld['hostName'] . "', " . " '" . $serverOld['port'] . "', '" . $serverOld['CPU'] . "', '" . $serverOld['memory'] . "', " . " '" . $serverOld['disk'] . "', '" . $serverOld['OS'] . "', '" . $serverOld['description'] . "', " . " '" . $serverOld['icon'] . "', '" . $serverOld['displayMode'] . "', '" . $serverOld['replacingText'] . "') ";
@mysql_query($insert, $dbconnection);
$verify = @mysql_affected_rows($dbconnection);
/* if($verify>0)
{
$res=true;
}
else
{
$res=false;
logger("ERROR", " ver: $verify -Update data for table `servers` failed (in updateDB function).");
} */
}
}
if ($res) {
//start sessions table update
$dbconnectionOld = @mysql_connect($dbHostOld, $dbAdminUsernameOld, $dbAdminPasswdOld);
if (@mysql_select_db($dbNameOld, $dbconnectionOld)) {
//.........这里部分代码省略.........
示例14: fopen
<?php
require "oodbCreate_inc.php";
$inFp = fopen($argv[1], 'r');
if (!$inFp) {
echo 'Konnte Datei nicht öffnen';
} else {
createDB($inFp, STDOUT);
}
示例15: error_reporting
// database server configuration
include "config.php";
// common functions
include "common/functions.php";
// strict error reporting while debugging
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// connect to db server
$connection = @mysql_connect($config["host"]["name"], $config["host"]["user"], $config["host"]["password"]) or die('Couldn\'t connect: ' . mysql_error());
// get the database list
$dbs = listDBs($connection);
$result = "";
// you really don't want to run this without user confirmation first
if (isset($_POST["create"]) && isset($_POST["filename"])) {
// create a new database
if (createDB($connection, $_POST["filename"]) == "") {
$result = "Created database.";
} else {
$result = "Couldn't connect, or database already exists.";
}
}
// disconnect from db server
mysql_close($connection);
?>
<!DOCTYPE html>
<html>
<head>