本文整理汇总了PHP中create_table函数的典型用法代码示例。如果您正苦于以下问题:PHP create_table函数的具体用法?PHP create_table怎么用?PHP create_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_database
function setup_database($new = false)
{
global $MYSQL_SERVER;
global $MYSQL_USER;
global $MYSQL_PASSWORD;
global $MYSQL_DATABASE;
echo "= DATABASE SETUP =" . PHP_EOL . PHP_EOL;
$conn = mysql_connect($MYSQL_SERVER, $MYSQL_USER, $MYSQL_PASSWORD);
if ($new) {
mysql_query("DROP DATABASE {$MYSQL_DATABASE}");
echo "Database {$database} dropped." . PHP_EOL;
}
mysql_query("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") or die(mysql_error());
echo "Database {$MYSQL_DATABASE} created." . PHP_EOL;
mysql_select_db($MYSQL_DATABASE, $conn);
mysql_set_charset("utf8");
if ($new) {
$dir = "database/";
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($file) && !endsWith($file, "_inserts.sql")) {
create_table($file);
}
}
}
}
insert_languages();
echo "Tables for {$MYSQL_DATABASE} created." . PHP_EOL;
}
}
示例2: check_cli_args
function check_cli_args($options)
{
if (array_key_exists('u', $options) && array_key_exists('p', $options) && array_key_exists('h', $options)) {
if (array_key_exists("create_table", $options)) {
if (array_key_exists("file", $options) || array_key_exists("dry_run", $options)) {
echo "\nCommand format not correct\n\n";
echo_usage();
} else {
echo "\nCreating users table\n\n";
create_table($options);
}
} else {
if (array_key_exists("file", $options) && array_key_exists("dry_run", $options)) {
echo "\nImporting file and doing dry run\n\n";
$dry_run = true;
csv_reader($dry_run, $options);
} else {
if (array_key_exists("file", $options)) {
echo "\nImporting file and doing commit\n\n";
$dry_run = false;
csv_reader($dry_run, $options);
}
}
}
} else {
if (array_key_exists("help", $options)) {
echo_usage();
} else {
echo "\nCommand format not correct\n\n";
echo_usage();
}
}
}
示例3: xmldb_artefact_calendar_upgrade
function xmldb_artefact_calendar_upgrade($oldversion = 0)
{
if ($oldversion < 2013062404) {
$table = new XMLDBTable('artefact_calendar_reminder');
drop_table($table);
$table->addFieldInfo('user', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('reminder_type', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL);
$table->addFieldInfo('reminder_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '-1', null);
$table->addKeyInfo('reminder_pk', XMLDB_KEY_PRIMARY, array('user'));
if (!create_table($table)) {
throw new SQLException($table . " could not be created, check log for errors.");
}
execute_sql('ALTER TABLE {artefact_calendar_calendar} DROP COLUMN {reminder_status}');
}
if ($oldversion < 2013062501) {
execute_sql('ALTER TABLE {artefact_calendar_calendar} change {reminder_date} {reminder_date} int(4) NOT NULL;');
}
if ($oldversion < 2013063001) {
$table = new XMLDBTable('artefact_calendar_event');
$table->addFieldInfo('eventid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('begin', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('end', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('whole_day', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
$table->addFieldInfo('repeat_type', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
$table->addFieldInfo('repeats_every', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
$table->addFieldInfo('end_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('ends_after', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
$table->addKeyInfo('event_pk', XMLDB_KEY_PRIMARY, array('eventid'));
if (!create_table($table)) {
throw new SQLException($table . " could not be created, check log for errors.");
}
}
return true;
}
示例4: sendgrid_sga_data_api
function sendgrid_sga_data_api()
{
header("Content-Type: application/json");
if ($_POST['api_key'] != get_option("sendgrid_sga_apikey")) {
$output = array("error" => true, "message" => "Unauthenticated.");
echo json_encode($output);
die;
}
$period_start = create_start_time($_POST['period_start'], true);
$period_end = create_end_time($_POST['period_end'], true);
create_table($period_start, $period_end);
$output = array("error" => true, "message" => "Unknown error.");
$body = array();
if ($_POST['data'] == "users") {
$top_users = get_top_users();
foreach ($top_users as $rank => $user_info) {
$formatted_user_info = format_user_info($user_info);
$body[] = array("raw" => array("post_author" => get_post_author($user_info->post_author), "mantime" => (int) $user_info->mantime, "visits" => (int) $user_info->visits, "pageviews" => (int) $user_info->pageviews, "avg_time_on_page" => (double) $user_info->avg_time_on_page, "entrance_rate" => (double) $user_info->entrance_rate, "exit_rate" => (double) $user_info->exit_rate), "formatted" => $formatted_user_info);
}
$output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end);
} elseif ($_POST['data'] == "posts") {
$top_posts = get_top_posts();
foreach ($top_posts as $rank => $post_info) {
$formatted_post_info = format_post_info($post_info);
$body[] = array("raw" => array("guid" => $post_info->guid, "post_title" => $post_info->post_title, "post_author" => get_post_author($post_info->post_author), "mantime" => (int) $post_info->mantime, "visits" => (int) $post_info->visits, "pageviews" => (int) $post_info->pageviews, "avg_time_on_page" => (double) $post_info->avg_time_on_page, "entrance_rate" => (double) $post_info->entrance_rate, "exit_rate" => (double) $post_info->exit_rate), "formatted" => $formatted_post_info);
}
$output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end);
} else {
$output = array("error" => true, "message" => "Data attribute not understood, please provide either users or posts");
}
echo json_encode($output);
die;
}
示例5: xmldb_blocktype_taggedposts_upgrade
function xmldb_blocktype_taggedposts_upgrade($oldversion = 0)
{
if ($oldversion < 2015011500) {
$table = new XMLDBTable('blocktype_taggedposts_tags');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL);
$table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype'));
if (!table_exists($table)) {
create_table($table);
$rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata');
while ($bi = $rs->FetchRow()) {
// Each block will have only one tag (because we combined this upgrade block
// with the upgrade block for the "multiple tags" enhancement.
$configdata = unserialize($bi['configdata']);
if (!empty($configdata['tagselect'])) {
$todb = new stdClass();
$todb->block_instance = $bi['id'];
$todb->tag = $configdata['tagselect'];
$todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE;
insert_record('blocktype_taggedposts_tags', $todb);
}
}
}
}
return true;
}
示例6: up
public function up()
{
// Get database handle
$dbh = $this->getdbh();
// Check if database is already migrated
try {
// This will cause an Exception if not migrated
$dbh->query("SELECT VolumeName FROM diskreport");
return TRUE;
} catch (Exception $e) {
// Not migrated, continue..
}
// Create temp table
create_table($this);
// Copy data into temp
$now = time();
$sql = "INSERT INTO diskreport_temp \n\t\t\t\t\tSELECT id, serial_number, TotalSize, FreeSpace, Percentage, SMARTStatus, CASE WHEN SolidState = 1 THEN 'ssd' ELSE 'hdd' END, 'unknown', 1, '/', 'Unknown', -1, {$now} FROM diskreport";
$this->exec($sql);
$sql = "DROP table diskreport";
$this->exec($sql);
$sql = "ALTER TABLE diskreport_temp RENAME TO diskreport";
$this->exec($sql);
// Build indexes
$this->tablename = 'diskreport';
$this->idx[] = array('serial_number');
$this->idx[] = array('VolumeType');
$this->idx[] = array('MountPoint');
$this->idx[] = array('VolumeName');
$this->set_indexes();
}
示例7: xmldb_block_ajax_marking_upgrade
function xmldb_block_ajax_marking_upgrade($oldversion = 0)
{
//echo "oldversion: ".$oldversion;
global $CFG, $THEME, $db;
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2007052901) {
//New version in version.php
/// Define table block_ajax_marking to be created
$table = new XMLDBTable('block_ajax_marking');
/// Adding fields to table block_ajax_marking
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
$table->addFieldInfo('assessmenttype', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null);
$table->addFieldInfo('assessmentid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
$table->addFieldInfo('showhide', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('groups', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
/// Adding keys to table block_ajax_marking
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('useridkey', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
/// Launch create table for block_ajax_marking
$result = $result && create_table($table);
}
// run this on every upgrade.
AMB_update_modules();
return $result;
}
示例8: format_sql
function format_sql($sql)
{
global $db;
$sql = str_replace("\r", "\n", $sql);
$ret = array();
$num = 0;
foreach (explode(";\n", trim($sql)) as $query) {
$queries = explode("\n", trim($query));
foreach ($queries as $query) {
$ret[$num] .= $query[0] == '#' || $query[0] . $query[1] == '--' ? '' : $query;
}
$num++;
}
unset($sql);
foreach ($ret as $query) {
$query = trim($query);
if ($query) {
if (substr($query, 0, 12) == 'CREATE TABLE') {
//$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
//echo '创建表:'.$name.' ... <font color="#0000EE">'.$lang['succeed'].'</font><br>';
$db->query(create_table($query));
} else {
$db->query($query);
}
}
}
}
示例9: xmldb_crlm_cluster_classification_upgrade
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package elis
* @subpackage curriculummanagement
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
*/
function xmldb_crlm_cluster_classification_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2010080502) {
/// Define table crlm_cluster_classification to be created
$table = new XMLDBTable('crlm_cluster_classification');
/// Adding fields to table crlm_cluster_classification
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('params', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
/// Adding keys to table crlm_cluster_classification
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('shortname_idx', XMLDB_KEY_UNIQUE, array('shortname'));
/// Launch create table for crlm_cluster_classification
$result = $result && create_table($table);
}
if ($result && $oldversion < 2010080503) {
require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
$field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
// make sure we're set as owner
if (!isset($field->owners['cluster_classification'])) {
$owner = new field_owner();
$owner->fieldid = $field->id;
$owner->plugin = 'cluster_classification';
$owner->add();
}
// make sure we have a default value set
if (!field_data::get_for_context_and_field(NULL, $field)) {
field_data::set_for_context_and_field(NULL, $field, 'regular');
}
$default = new clusterclassification();
$default->shortname = 'regular';
$default->name = get_string('cluster', 'block_curr_admin');
$default->param_autoenrol_curricula = 1;
$default->param_autoenrol_tracks = 1;
$default->add();
}
// make sure 'manual' is an owner
if ($result && $oldversion < 2010080504) {
require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
$field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
$owner = new field_owner();
$owner->fieldid = $field->id;
$owner->plugin = 'manual';
$owner->param_view_capability = '';
$owner->param_edit_capability = 'moodle/user:update';
$owner->param_control = 'menu';
$owner->param_options_source = 'cluster_classifications';
$owner->add();
}
return $result;
}
示例10: execute
public function execute()
{
global $settings;
global $APP;
if ($APP['db']->connect()) {
if ($APP['db']->kind == "mysql") {
$APP['db']->query("CREATE TABLE IF NOT EXISTS assign_hf (\n id_user varchar(50) NOT NULL DEFAULT 'undefined',\n hf_server varchar(100) NOT NULL DEFAULT 'undefined',\n PRIMARY KEY (id_user,hf_server)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
$APP['db']->query("CREATE TABLE IF NOT EXISTS assign_server (\n id_user varchar(50) NOT NULL DEFAULT 'undefined',\n server_hf varchar(100) NOT NULL DEFAULT 'undefined',\n PRIMARY KEY (id_user,server_hf)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
$APP['db']->query("ALTER TABLE `user_server` ADD `int_online` VARCHAR(1) NOT NULL DEFAULT '1' AFTER `is_busy`");
}
if ($APP['db']->kind == "mssql") {
$APP['db']->query("SET ANSI_NULLS ON;\nSET QUOTED_IDENTIFIER ON;\nSET ANSI_PADDING ON;\nCREATE TABLE [dbo].[assign_hf](\n [id_user] [varchar](50) NOT NULL DEFAULT ('undefined'),\n [hf_server] [varchar](100) NOT NULL DEFAULT ('undefined'),\n CONSTRAINT [primary pkey_assign_hf] PRIMARY KEY CLUSTERED\n(\n [id_user] ASC,\n [hf_server] ASC\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n) ON [PRIMARY];\nSET ANSI_PADDING OFF;");
$APP['db']->query("SET ANSI_NULLS ON;\nSET QUOTED_IDENTIFIER ON;\nSET ANSI_PADDING ON;\nCREATE TABLE [dbo].[assign_server](\n [id_user] [varchar](50) NOT NULL DEFAULT ('undefined'),\n [server_hf] [varchar](100) NOT NULL DEFAULT ('undefined'),\n CONSTRAINT [primary pkey_assign_server] PRIMARY KEY CLUSTERED\n(\n [id_user] ASC,\n [server_hf] ASC\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n) ON [PRIMARY];\nSET ANSI_PADDING OFF;\n");
$APP['db']->query("ALTER TABLE dbo.user_server ADD \nint_online varchar(1) NOT NULL \nDEFAULT ('1') \nGO \nEXEC user_server;\nGO");
}
if ($APP['db']->kind == "oracle") {
$query_string = " CREATE TABLE 'DBNAME'.'ASSIGN_HF'\n ( 'ID_USER' VARCHAR2(50 BYTE) DEFAULT 'undefined',\n 'HF_SERVER' VARCHAR2(100 BYTE) DEFAULT 'undefined',\n ) SEGMENT CREATION IMMEDIATE\n PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n CREATE UNIQUE INDEX 'DBNAME'.'PKEY_ASSIGN_HF' ON 'DBNAME'.'ASSIGN_HF' ('ID_USER', 'HF_SERVER')\n PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n ALTER TABLE 'DBNAME'.'ASSIGN_HF' ADD CONSTRAINT 'PKEY_ASSIGN_HF' PRIMARY KEY ('ID_USER', 'HF_SERVER')\n USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ENABLE;\n ALTER TABLE 'DBNAME'.'ASSIGN_HF' MODIFY ('ID_USER' NOT NULL ENABLE);\n ALTER TABLE 'DBNAME'.'ASSIGN_HF' MODIFY ('HF_SERVER' NOT NULL ENABLE);";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
$query_string = " CREATE TABLE 'DBNAME'.'ASSIGN_SERVER'\n ( 'ID_USER' VARCHAR2(50 BYTE) DEFAULT 'undefined',\n 'SERVER_HF' VARCHAR2(100 BYTE) DEFAULT 'undefined',\n ) SEGMENT CREATION IMMEDIATE\n PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n CREATE UNIQUE INDEX 'DBNAME'.'PKEY_ASSIGN_SERVER' ON 'DBNAME'.'ASSIGN_SERVER' ('ID_USER', 'SERVER_HF')\n PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n ALTER TABLE 'DBNAME'.'ASSIGN_SERVER' ADD CONSTRAINT 'PKEY_ASSIGN_SERVER' PRIMARY KEY ('ID_USER', 'SERVER_HF')\n USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ENABLE;\n ALTER TABLE 'DBNAME'.'ASSIGN_SERVER' MODIFY ('ID_USER' NOT NULL ENABLE);\n ALTER TABLE 'DBNAME'.'ASSIGN_SERVER' MODIFY ('SERVER_HF' NOT NULL ENABLE);";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
$APP['db']->query("ALTER TABLE\n user_server \nADD\n int_online varchar2(1) DEFAULT '1' NOT NULL;");
}
if ($APP['db']->kind == "postgres") {
$APP['db']->query("CREATE TABLE assign_hf (\n id_user character varying(50) DEFAULT 'undefined'::character varying NOT NULL,\n hf_server character varying(100) DEFAULT 'undefined'::character varying NOT NULL\n);\nALTER TABLE public.assign_hf OWNER TO USERNAME;\nALTER TABLE ONLY assign_hf ADD CONSTRAINT assign_hf_pkey PRIMARY KEY (id_user, hf_server);");
$APP['db']->query("CREATE TABLE assign_server (\n id_user character varying(50) DEFAULT 'undefined'::character varying NOT NULL,\n server_hf character varying(100) DEFAULT 'undefined'::character varying NOT NULL\n);\nALTER TABLE public.assign_server OWNER TO USERNAME;\nALTER TABLE ONLY assign_server ADD CONSTRAINT assign_server_pkey PRIMARY KEY (id_user, server_hf);");
$APP['db']->query("ALTER TABLE user_server ADD COLUMN int_online character varying(1) DEFAULT '1'::character varying NOT NULL");
}
if ($APP['db']->kind == "mongodb") {
try {
$c = $APP['db']->db->selectDB($APP['db']->dbname)->createCollection("assign_hf");
$c->ensureIndex(array("id_user" => 1, "hf_server" => 1), array("unique" => 1, "dropDups" => 1));
} catch (Exception $e) {
print_r($e);
}
try {
$c = $APP['db']->db->selectDB($APP['db']->dbname)->createCollection("assign_server");
$c->ensureIndex(array("id_user" => 1, "server_hf" => 1), array("unique" => 1, "dropDups" => 1));
} catch (Exception $e) {
print_r($e);
}
}
if ($APP['db']->kind == "dynamodb") {
$_POST['substep'] = -1;
include "schemas/db-schema-dynamodb.sql";
create_table("assign_hf", false, "id_user", "hf_server");
echo " ";
create_table("assign_server", false, "id_user", "server_hf");
echo " ";
}
}
}
示例11: zinchinfo
function zinchinfo()
{
$svn_table = create_table(zinchInfo_revision());
$php_server_table = create_table($_SERVER);
$final_output = '<div class="center_z">';
$final_output = $final_output . css_style() . create_table_header();
$final_output = $final_output . "<br>" . $svn_table;
$final_output = $final_output . "<br>" . $php_server_table;
$final_output = $final_output . '</div>';
return $final_output;
}
示例12: wrsqz_create_table
function wrsqz_create_table($table)
{
if (table_exists($table, true, false)) {
return wrsqz_update_table($table);
} else {
if (create_table($table, true, false)) {
return CREATED_TABLE;
} else {
return DB_ERROR;
}
}
}
示例13: _run_sql
function _run_sql($sqls)
{
if (is_string($sqls)) {
$sqls = get_sql($sqls);
}
if (!is_array($sqls)) {
return true;
}
// 检查可能在某次补丁中已经添加过的字段
// 检查哪些字段
$check_fields = array('ecm_order' => array('pay_alter'), 'ecm_store' => array('enable_radar', 'enable_groupbuy'));
// 哪些在数据库中已经存在
$exist_fields = array();
foreach ($check_fields as $table => $fields) {
$result = $this->db->query("SELECT * FROM `{$table}` limit 1");
$i = 0;
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result);
if (in_array($meta->name, $fields)) {
$exist_fields[$table][] = $meta->name;
}
$i++;
}
}
foreach ($sqls as $sql) {
$need_exec = true;
foreach ($exist_fields as $table => $fields) {
foreach ($fields as $field) {
$pattern = "/alter\\s+table\\s+`?{$table}`?\\s+add\\s+`?{$field}`?\\s+/Uis";
if (preg_match($pattern, $sql)) {
// 该sql语句不需要执行
$need_exec = false;
break;
}
}
}
if ($need_exec) {
substr($sql, 0, 12) == 'CREATE TABLE' && ($sql = create_table($sql));
$query = $this->db->query($sql, 'SILENT');
if (!$query) {
$this->_error($this->db->error());
return false;
}
}
}
return true;
}
示例14: execute
public function execute()
{
global $APP;
if ($APP['db']->connect()) {
if ($APP['db']->kind == "mysql") {
$query_string = "CREATE TABLE IF NOT EXISTS user_server_service (\n id_user_server varchar(50) NOT NULL DEFAULT 'undefined',\n service_name varchar(50) NOT NULL DEFAULT 'undefined',\n service_enabled varchar(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (id_user_server,service_name)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
}
if ($APP['db']->kind == "mssql") {
$query_string = "SET ANSI_NULLS ON;\nSET QUOTED_IDENTIFIER ON;\nSET ANSI_PADDING ON;\nCREATE TABLE [dbo].[user_server_service](\n\t[id_user_server] [varchar](50) NOT NULL DEFAULT ('undefined'),\n\t[service_name] [varchar](50) NOT NULL DEFAULT ('undefined'),\n\t[service_enabled] [varchar](1) NOT NULL DEFAULT ('0'),\n CONSTRAINT [primary pkey_user_server_service] PRIMARY KEY CLUSTERED \n(\n\t[id_user_server] ASC,\n\t[service_name] ASC\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n) ON [PRIMARY];\nSET ANSI_PADDING OFF;";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
}
if ($APP['db']->kind == "oracle") {
$query_string = " CREATE TABLE 'DBNAME'.'USER_SERVER_SERVICE'\n ( 'ID_USER_SERVER' VARCHAR2(50 BYTE) DEFAULT '',\n 'SERVICE_NAME' VARCHAR2(50 BYTE) DEFAULT '',\n 'SERVICE_ENABLED' VARCHAR2(1 BYTE) DEFAULT '0',\n ) SEGMENT CREATION IMMEDIATE\n PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n CREATE UNIQUE INDEX 'DBNAME'.'PKEY_USER_SERVER_SERVICE' ON 'DBNAME'.'USER_SERVER_SERVICE' ('ID_USER_SERVER', 'SERVICE_NAME')\n PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ;\n\n ALTER TABLE 'DBNAME'.'USER_SERVER_SERVICE' ADD CONSTRAINT 'PKEY_USER_SERVER_SERVICE' PRIMARY KEY ('ID_USER_SERVER', 'SERVICE_NAME')\n USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255\n STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645\n PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)\n TABLESPACE 'USERS' ENABLE;\n ALTER TABLE 'DBNAME'.'USER_SERVER_SERVICE' MODIFY ('ID_USER_SERVER' NOT NULL ENABLE);\n ALTER TABLE 'DBNAME'.'USER_SERVER_SERVICE' MODIFY ('SERVICE_NAME' NOT NULL ENABLE);\n ALTER TABLE 'DBNAME'.'USER_SERVER_SERVICE' MODIFY ('SERVICE_ENABLED' NOT NULL ENABLE);";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
}
if ($APP['db']->kind == "postgres") {
$query_string = "CREATE TABLE user_server_service (\n id_user_server character varying(50) DEFAULT 'undefined'::character varying NOT NULL,\n service_name character varying(50) DEFAULT 'undefined'::character varying NOT NULL,\n service_enabled character varying(1) DEFAULT '0'::character varying NOT NULL\n);\nALTER TABLE public.user_server_service OWNER TO USERNAME;\nALTER TABLE ONLY user_server_service ADD CONSTRAINT user_server_service_pkey PRIMARY KEY (id_user_server, service_name);";
$query_string = str_replace("(SEMICOLON)", ";", $query_string);
$query_string = str_replace("DBNAME", strtoupper($APP['db']->dbname), $query_string);
$query_string = str_replace("USERNAME", $APP['db']->auth1, $query_string);
$APP['db']->query($query_string);
}
if ($APP['db']->kind == "mongodb") {
try {
$c = $APP['db']->db->selectDB($APP['db']->dbname)->createCollection("user_server_service");
$c->ensureIndex(array("id_user_server" => 1, "service_name" => 1), array("unique" => 1, "dropDups" => 1));
} catch (Exception $e) {
print_r($e);
}
}
if ($APP['db']->kind == "dynamodb") {
$_POST['substep'] = -1;
include "schemas/db-schema-dynamodb.sql";
create_table("user_server_service", false, "id_user_server", "service_name");
}
}
}
示例15: xmldb_qtype_rqp_upgrade
function xmldb_qtype_rqp_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2006032201) {
$table = new XMLDBTable('question_rqp_servers');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('typeid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('url', XMLDB_TYPE_CHAR, 255);
$table->addFieldInfo('can_render', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('can_author', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('typeid', XMLDB_KEY_FOREIGN, array('typeid'), 'rqp_types', array('id'));
$result = $result && create_table($table);
}
return $result;
}