当前位置: 首页>>代码示例>>PHP>>正文


PHP DBLayer::start_transaction方法代码示例

本文整理汇总了PHP中DBLayer::start_transaction方法的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer::start_transaction方法的具体用法?PHP DBLayer::start_transaction怎么用?PHP DBLayer::start_transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBLayer的用法示例。


在下文中一共展示了DBLayer::start_transaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: error

         }
         break;
 }
 // Make sure PunBB isn't already installed
 $result = $db->query('SELECT 1 FROM ' . $db_prefix . 'users WHERE id=1');
 if ($db->num_rows($result)) {
     error('A table called "' . $db_prefix . 'users" is already present in the database "' . $db_name . '". This could mean that PunBB is already installed or that another piece of software is installed and is occupying one or more of the table names PunBB requires. If you want to install multiple copies of PunBB in the same database, you must choose a different table prefix.');
 }
 // Create all tables
 switch ($db_type) {
     case 'mysql':
     case 'mysqli':
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT(10) UNSIGNED,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
         break;
     case 'pgsql':
         $db->start_transaction();
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
         break;
     case 'sqlite':
         $db->start_transaction();
         $sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INTEGER NOT NULL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip  VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INTEGER,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
         break;
 }
 $db->query($sql) or error('Unable to create table ' . $db_prefix . 'bans. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
 switch ($db_type) {
     case 'mysql':
     case 'mysqli':
         $sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT(10) NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
         break;
     case 'pgsql':
         $sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
开发者ID:BackupTheBerlios,项目名称:vnkb-applet-svn,代码行数:31,代码来源:install.php

示例2: error

     error(sprintf($lang_install['Invalid table prefix'], $db_prefix));
 }
 // Check SQLite prefix collision
 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);
开发者ID:heiswayi,项目名称:ishare-plus,代码行数:31,代码来源:install.php


注:本文中的DBLayer::start_transaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。