本文整理汇总了PHP中DBLayer::create_table方法的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer::create_table方法的具体用法?PHP DBLayer::create_table怎么用?PHP DBLayer::create_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBLayer
的用法示例。
在下文中一共展示了DBLayer::create_table方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list
// Check if InnoDB is available
if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
list(, $result) = $db->fetch_row($result);
if (strtoupper($result) != 'YES') {
error($lang_install['InnoDB off']);
}
}
// Start a transaction
$db->start_transaction();
// Create all tables
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'username' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'ip' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'email' => array('datatype' => 'VARCHAR(80)', 'allow_null' => true), 'message' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'expire' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'ban_creator' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'), 'INDEXES' => array('username_idx' => array('username')));
if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$schema['INDEXES']['username_idx'] = array('username(25)');
}
$db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'cat_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New Category\''), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'search_for' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\''), 'replace_with' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
$db->create_table('censoring', $schema) or error('Unable to create censoring table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('conf_name' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'conf_value' => array('datatype' => 'TEXT', 'allow_null' => true)), 'PRIMARY KEY' => array('conf_name'));
$db->create_table('config', $schema) or error('Unable to create config table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('group_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'forum_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'read_forum' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1')), 'PRIMARY KEY' => array('group_id', 'forum_id'));
$db->create_table('forum_perms', $schema) or error('Unable to create forum_perms table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'forum_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New forum\''), 'forum_desc' => array('datatype' => 'TEXT', 'allow_null' => true), 'redirect_url' => array('datatype' => 'VARCHAR(100)', 'allow_null' => true), 'moderators' => array('datatype' => 'TEXT', 'allow_null' => true), 'num_topics' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'num_posts' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'last_post' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_post_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_poster' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'sort_by' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'cat_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$db->create_table('forums', $schema) or error('Unable to create forums table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('g_id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'g_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'g_user_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => true), 'g_promote_min_posts' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'g_promote_next_group' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'g_moderator' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_edit_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_rename_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_change_passwords' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_ban_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_promote_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_read_board' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_view_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_edit_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_links' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_set_title' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_send_email' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_search_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_email_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60'), 'g_report_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60')), 'PRIMARY KEY' => array('g_id'));
$db->create_table('groups', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('user_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '1'), 'ident' => array('datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\''), 'logged' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'idle' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'last_post' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_search' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true)), 'UNIQUE KEYS' => array('user_id_ident_idx' => array('user_id', 'ident')), 'INDEXES' => array('ident_idx' => array('ident'), 'logged_idx' => array('logged')));
if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)');
示例2: error
if (in_array($db_type, array('sqlite', 'sqlite3')) && strtolower($db_prefix) == 'sqlite_') {
error($lang_install['SQLite prefix collision']);
}
// Make sure PunBB isn't already installed
if ($forum_db->table_exists('users')) {
$query = array('SELECT' => 'COUNT(id)', 'FROM' => 'users', 'WHERE' => 'id=1');
$result = $forum_db->query_build($query);
if ($forum_db->result($result) > 0) {
error(sprintf($lang_install['PunBB already installed'], $db_prefix, $db_name));
}
}
// Start a transaction
$forum_db->start_transaction();
// Create all tables
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'username' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'ip' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'email' => array('datatype' => 'VARCHAR(80)', 'allow_null' => true), 'message' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'expire' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'ban_creator' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$forum_db->create_table('bans', $schema);
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'cat_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New Category\''), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$forum_db->create_table('categories', $schema);
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'search_for' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\''), 'replace_with' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
$forum_db->create_table('censoring', $schema);
$schema = array('FIELDS' => array('conf_name' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'conf_value' => array('datatype' => 'TEXT', 'allow_null' => true)), 'PRIMARY KEY' => array('conf_name'));
$forum_db->create_table('config', $schema);
$schema = array('FIELDS' => array('id' => array('datatype' => 'VARCHAR(150)', 'allow_null' => false, 'default' => '\'\''), 'title' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'version' => array('datatype' => 'VARCHAR(25)', 'allow_null' => false, 'default' => '\'\''), 'description' => array('datatype' => 'TEXT', 'allow_null' => true), 'author' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'uninstall' => array('datatype' => 'TEXT', 'allow_null' => true), 'uninstall_note' => array('datatype' => 'TEXT', 'allow_null' => true), 'disabled' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'dependencies' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
$forum_db->create_table('extensions', $schema);
$schema = array('FIELDS' => array('id' => array('datatype' => 'VARCHAR(150)', 'allow_null' => false, 'default' => '\'\''), 'extension_id' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'code' => array('datatype' => 'TEXT', 'allow_null' => true), 'installed' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'priority' => array('datatype' => 'TINYINT(1) UNSIGNED', 'allow_null' => false, 'default' => '5')), 'PRIMARY KEY' => array('id', 'extension_id'));
$forum_db->create_table('extension_hooks', $schema);
$schema = array('FIELDS' => array('group_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'forum_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'read_forum' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1')), 'PRIMARY KEY' => array('group_id', 'forum_id'));
$forum_db->create_table('forum_perms', $schema);
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'forum_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New forum\''), 'forum_desc' => array('datatype' => 'TEXT', 'allow_null' => true), 'redirect_url' => array('datatype' => 'VARCHAR(100)', 'allow_null' => true), 'moderators' => array('datatype' => 'TEXT', 'allow_null' => true), 'num_topics' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'num_posts' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'last_post' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_post_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_poster' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'sort_by' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'cat_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$forum_db->create_table('forums', $schema);
$schema = array('FIELDS' => array('g_id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'g_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'g_user_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => true), 'g_moderator' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_edit_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_rename_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_change_passwords' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_ban_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_read_board' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_view_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_edit_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_set_title' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_send_email' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_search_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_email_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60')), 'PRIMARY KEY' => array('g_id'));