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


PHP DBUtil::table_exists方法代码示例

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


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

示例1: action_index

 public function action_index()
 {
     if (!\DBUtil::table_exists('blog') && !\DBUtil::table_exists('blog_comment')) {
         \Response::redirect('blog/installrequired');
     }
     // list posts -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     $list_items = \Blog\Model_Blog::listItems($option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_items['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_items'] = $list_items;
     $output['pagination'] = $pagination;
     unset($config, $list_accounts, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('blog'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('blog_v', $output, false);
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:34,代码来源:blog.php

示例2: create

 /**
  * create the sessions table
  * php oil r session:create
  */
 public static function create()
 {
     // load session config
     \Config::load('session', true);
     if (\Config::get('session.driver') != 'db') {
         // prompt the user to confirm they want to remove the table.
         $continue = \Cli::prompt(\Cli::color('Your current driver type is not set db. Would you like to continue and add the sessions table anyway?', 'yellow'), array('y', 'n'));
         if ($continue === 'n') {
             return \Cli::color('Database sessions table was not created.', 'red');
         }
     }
     if (\DBUtil::table_exists(\Config::get('session.db.table'))) {
         return \Cli::write('Session table already exists.');
     }
     // create the session table using the table name from the config file
     \DBUtil::create_table(\Config::get('session.db.table'), array('session_id' => array('constraint' => 40, 'type' => 'varchar'), 'previous_id' => array('constraint' => 40, 'type' => 'varchar'), 'user_agent' => array('type' => 'text', 'null' => false), 'ip_hash' => array('constraint' => 32, 'type' => 'char'), 'created' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'updated' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'payload' => array('type' => 'longtext')), array('session_id'), false, 'InnoDB', \Config::get('db.default.charset'));
     // make previous_id a unique_key. speeds up query and prevents duplicate id's
     \DBUtil::create_index(\Config::get('session.db.table'), 'previous_id', 'previous_id', 'unique');
     if (\Config::get('session.driver') === 'db') {
         // return success message.
         return \Cli::color('Success! Your session table has been created!', 'green');
     } else {
         // return success message notifying that the driver is not db.
         return \Cli::color('Success! Your session table has been created! Your current session driver type is set to ' . \Config::get('session.driver') . '. In order to use the table you just created to manage your sessions, you will need to set your driver type to "db" in your session config file.', 'green');
     }
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:30,代码来源:session.php

示例3: empty_table

 protected static function empty_table($table)
 {
     if (DBUtil::table_exists($table)) {
         DBUtil::truncate_table($table);
     } else {
         exit('No such table: ' . $table . PHP_EOL);
     }
 }
开发者ID:sato5603,项目名称:fuelphp1st-2nd,代码行数:8,代码来源:dbfixture.php

示例4: up

 function up()
 {
     // only do this if it doesn't exist yet
     if (!\DBUtil::table_exists('users')) {
         // table users
         \DBUtil::create_table('users', array('id' => array('type' => 'integer primary key', 'autoincrement' => true), 'username' => array('type' => 'text'), 'password' => array('type' => 'text'), 'group' => array('type' => 'integer', 'default' => 1), 'email' => array('type' => 'text'), 'last_login' => array('type' => 'text'), 'login_hash' => array('type' => 'text'), 'profile_fields' => array('type' => 'text'), 'created_at' => array('type' => 'integer', 'default' => 0), 'updated_at' => array('type' => 'integer', 'default' => 0)));
         // add a unique index on username and email
         \DBUtil::create_index('users', array('username', 'email'), 'username', 'UNIQUE');
     }
 }
开发者ID:takasick,项目名称:cms-forge,代码行数:10,代码来源:001_create_users.php

示例5: action_uninstall

 public function action_uninstall()
 {
     if (\DBUtil::table_exists('blog')) {
         \DBUtil::drop_table('blog');
     }
     if (\DBUtil::table_exists('blog_comment')) {
         \DBUtil::drop_table('blog_comment');
     }
     echo 'Uninstall db tables for blog module completed.';
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:10,代码来源:setup.php

示例6: up

 public function up()
 {
     if (\DBUtil::table_exists('task_queues')) {
         return;
     }
     // -------------------------
     // task_queues
     // -------------------------
     \DBUtil::create_table('task_queues', array('id' => array('type' => 'int', 'constraint' => 10, 'unsigned' => true, 'auto_increment' => true), 'method' => array('type' => 'varchar', 'constraint' => 255), 'options' => array('type' => 'varchar', 'constraint' => 255, 'comment' => 'json format'), 'duplicate_type' => array('type' => 'tinyint', 'default' => 0, 'comment' => '0:no limit setting, 1~:limit is refered from config file'), 'job_status' => array('type' => 'tinyint', 'default' => 0, 'comment' => '0:wait, 1:exec, 2:success, 3:error'), 'deleted' => array('type' => 'tinyint', 'default' => \Config::get('queue.logical_delete.not_deleted')), 'created_at' => array('type' => 'datetime', 'null' => true), 'updated_at' => array('type' => 'datetime', 'null' => true), 'timestamp' => array('type' => 'timestamp', 'default' => \DB::expr('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))), array('id'), true, 'InnoDB', 'utf8');
 }
开发者ID:hinashiki,项目名称:fuelphp-queue,代码行数:10,代码来源:001_queue_create_task_queues_table.php

示例7: actionAccountDeleteOnMultisiteTables

 public function actionAccountDeleteOnMultisiteTables($account_id = '', $args = '')
 {
     $test_table_name = 'testmultisiteaccount';
     // get all sites from site table
     $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
     if ($sites_result != null) {
         foreach ($sites_result as $site) {
             if ($site->site_id == '1') {
                 $test_table = 'testmultisiteaccount';
             } else {
                 $test_table = $site->site_id . '_testmultisiteaccount';
             }
             if (\DBUtil::table_exists($test_table)) {
                 \DB::delete($test_table)->where('account_id', $account_id)->execute();
             }
         }
     }
     unset($site, $sites_result, $test_table, $test_table_name);
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:19,代码来源:testmod_module.php

示例8: up

 public function up()
 {
     //populate the system roles if they don't exist
     if (\DBUtil::table_exists('roles')) {
         if (\DB::count_records('roles') == 0) {
             $roles = array(\Access::ROLE_ADMIN => 'Admin', \Access::ROLE_DEVELOPER => 'Developer', \Access::ROLE_EDITOR => 'Editor', \Access::ROLE_PENDING => 'Pending', \Access::ROLE_STANDARD => 'Standard', \Access::ROLE_SILVER => 'Silver', \Access::ROLE_GOLD => 'Gold', \Access::ROLE_DUMMY => 'Dummy');
             foreach ($roles as $id => $role) {
                 \DB::insert('roles')->set(array('id' => $id, 'name' => strtolower($role), 'Description' => $role))->execute();
             }
             \Cli::write("\nPopulated roles.");
         }
     }
     //create default admin user if we have no users
     if (\DBUtil::table_exists('users')) {
         if (\DB::count_records('users') == 0) {
             //create the admin user
             $data = array('username' => \Cli::prompt("Please enter an admin username"), 'email' => \Cli::prompt("Please enter an admin email"), 'password' => \Cli::prompt("Please enter an admin password"));
             try {
                 $user = new \Warden\Model_User($data);
                 if (\Config::get('warden.confirmable.in_use') === true) {
                     $user->is_confirmed = true;
                 }
                 \Access::set_roles(array(\Access::ROLE_STANDARD, \Access::ROLE_ADMIN), $user);
                 //this will assign the roles and save the user
                 \Cli::write("\nCreated admin user.");
                 \Cli::write(\Cli::color("\nUsername : {$user->username}", 'blue'));
                 \Cli::write(\Cli::color("\nEmail    : {$user->email}", 'blue'));
             } catch (\Exception $e) {
                 \Cli::error("\n:( Failed to create admin user because: " . $e->getMessage());
             }
         }
     }
     //create the blog table if it doesnt exist
     if (!\DBUtil::table_exists('blogs')) {
         \DBUtil::create_table('blogs', array('id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true, 'auto_increment' => true), 'user_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'title' => array('constraint' => 255, 'type' => 'varchar'), 'post' => array('type' => 'text'), 'publish_flag' => array('constraint' => 11, 'type' => 'int', 'default' => 0, 'unsigned' => true), 'public_flag' => array('constraint' => 11, 'type' => 'int', 'default' => 0, 'unsigned' => true), 'created_at' => array('type' => 'timestamp', 'default' => \DB::expr('CURRENT_TIMESTAMP')), 'updated_at' => array('type' => 'timestamp')), array('id'), true, 'InnoDB');
         \DBUtil::create_index('blogs', 'user_id', 'user_id');
     }
 }
开发者ID:jkapelner,项目名称:chatroom-web-server,代码行数:38,代码来源:001_create_tables.php

示例9: run

 public static function run()
 {
     // create permission table. (user's permission)
     $sql = "CREATE TABLE IF NOT EXISTS `" . \DB::table_prefix('account_permission') . "` (\n            `permission_id` int(11) NOT NULL AUTO_INCREMENT,\n            `account_id` int(11) NOT NULL COMMENT 'refer to accounts.account_id',\n            `permission_core` int(1) NOT NULL DEFAULT '0' COMMENT '1=core permission, 0=modules permission',\n            `module_system_name` varchar(255) DEFAULT NULL COMMENT 'module system name',\n            `permission_page` varchar(255) NOT NULL,\n            `permission_action` varchar(255) DEFAULT NULL,\n            PRIMARY KEY (`permission_id`),\n            KEY `account_id` (`account_id`)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='contain user''s permission for each admin page and action.' AUTO_INCREMENT=1 ;";
     \DB::query($sql)->execute();
     unset($sql);
     // loop sites to create permission table.
     $sites = \Model_Sites::find('all');
     if ($sites != null) {
         foreach ($sites as $row) {
             $table_name = 'account_permission';
             if ($row->site_id != '1') {
                 $table_name = $row->site_id . '_' . $table_name;
             }
             if (!\DBUtil::table_exists($table_name)) {
                 $sql = 'CREATE TABLE IF NOT EXISTS ' . \DB::table_prefix($table_name) . ' LIKE ' . \DB::table_prefix('account_permission');
                 \DB::query($sql)->execute();
                 unset($sql);
             }
         }
     }
     unset($row, $sites);
     return true;
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:24,代码来源:update0002.php

示例10: usertable

 protected static function usertable()
 {
     if (!\DBUtil::table_exists(static::$data['ormauth_table'])) {
         if (!\DBUtil::table_exists(static::$data['simpleauth_table'])) {
             // table users
             \DBUtil::create_table(static::$data['ormauth_table'], array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50), 'password' => array('type' => 'varchar', 'constraint' => 255), 'group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1), 'email' => array('type' => 'varchar', 'constraint' => 255), 'last_login' => array('type' => 'varchar', 'constraint' => 25), 'previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0), 'login_hash' => array('type' => 'varchar', 'constraint' => 255), 'user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0)), array('id'));
             // add a unique index on username and email
             \DBUtil::create_index(static::$data['ormauth_table'], array('username', 'email'), 'username', 'UNIQUE');
         } else {
             \DBUtil::rename_table(static::$data['simpleauth_table'], static::$data['ormauth_table']);
         }
     }
     // run a check on required fields, and deal with missing ones. we might be migrating from simpleauth
     if (\DBUtil::field_exists(static::$data['ormauth_table'], 'group')) {
         \DBUtil::modify_fields(static::$data['ormauth_table'], array('group' => array('name' => 'group_id', 'type' => 'int', 'constraint' => 11)));
     }
     if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'group_id')) {
         \DBUtil::add_fields(static::$data['ormauth_table'], array('group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1, 'after' => 'password')));
     }
     if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'previous_login')) {
         \DBUtil::add_fields(static::$data['ormauth_table'], array('previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0, 'after' => 'last_login')));
     }
     if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'user_id')) {
         \DBUtil::add_fields(static::$data['ormauth_table'], array('user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'login_hash')));
     }
     if (\DBUtil::field_exists(static::$data['ormauth_table'], 'created')) {
         \DBUtil::modify_fields(static::$data['ormauth_table'], array('created' => array('name' => 'created_at', 'type' => 'int', 'constraint' => 11)));
     }
     if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'created_at')) {
         \DBUtil::add_fields(static::$data['ormauth_table'], array('created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'user_id')));
     }
     if (\DBUtil::field_exists(static::$data['ormauth_table'], 'updated')) {
         \DBUtil::modify_fields(static::$data['ormauth_table'], array('updated' => array('name' => 'updated_at', 'type' => 'int', 'constraint' => 11)));
     }
     if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'updated_at')) {
         \DBUtil::add_fields(static::$data['ormauth_table'], array('updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'created_at')));
     }
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:38,代码来源:simple2orm.php

示例11: table_version_check

 /**
  * installs or upgrades the migration table to the current schema
  *
  * @return	void
  *
  * @deprecated	Remove upgrade check in 1.4
  */
 protected static function table_version_check()
 {
     // set connection
     static::$connection === null or \DBUtil::set_connection(static::$connection);
     // if table does not exist
     if (!\DBUtil::table_exists(static::$table)) {
         // create table
         \DBUtil::create_table(static::$table, static::$table_definition);
     } elseif (!\DBUtil::field_exists(static::$table, array('migration'))) {
         // get the current migration status
         $current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array();
         // drop the existing table, and recreate it in the new layout
         \DBUtil::drop_table(static::$table);
         \DBUtil::create_table(static::$table, static::$table_definition);
         // check if we had a current migration status
         if (!empty($current)) {
             // do we need to migrate from a v1.0 migration environment?
             if (isset($current[0]['current'])) {
                 // convert the current result into a v1.1. migration environment structure
                 $current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current']));
             }
             // build a new config structure
             $configs = array();
             // convert the v1.1 structure to the v1.2 structure
             foreach ($current as $migration) {
                 // find the migrations for this entry
                 $migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']);
                 // array to keep track of the migrations already run
                 $config = array();
                 // add the individual migrations found
                 foreach ($migrations as $file) {
                     $file = pathinfo($file['path']);
                     // add this migration to the table
                     \DB::insert(static::$table)->set(array('name' => $migration['name'], 'type' => $migration['type'], 'migration' => $file['filename']))->execute(static::$connection);
                     // and to the config
                     $config[] = $file['filename'];
                 }
                 // create a config entry for this name and type if needed
                 isset($configs[$migration['type']]) or $configs[$migration['type']] = array();
                 $configs[$migration['type']][$migration['name']] = $config;
             }
             // write the updated migrations config back
             \Config::set('migrations.version', $configs);
             \Config::save(\Fuel::$env . DS . 'migrations', 'migrations');
         }
         // delete any old migration config file that may exist
         is_file(APPPATH . 'config' . DS . 'migrations.php') and unlink(APPPATH . 'config' . DS . 'migrations.php');
     }
     // set connection to default
     static::$connection === null or \DBUtil::set_connection(null);
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:58,代码来源:migrate.php

示例12: table_check

 /**
  * Installs or upgrades migration table
  *
  * @return  void
  * @deprecated	Remove upgrade check in 1.2
  */
 private static function table_check()
 {
     // if table does not exist
     if (!\DBUtil::table_exists(static::$table)) {
         // create table
         \DBUtil::create_table(static::$table, static::$table_definition);
     } elseif (!\DBUtil::field_exists(static::$table, array('name', 'type'))) {
         $current = \DB::select('current')->from(static::$table)->limit(1)->execute()->get('current');
         \DBUtil::drop_table(static::$table);
         \DBUtil::create_table(static::$table, static::$table_definition);
         \DB::insert(static::$table)->set(array('name' => 'default', 'type' => 'app', 'version' => (int) $current))->execute();
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:19,代码来源:migrate.php

示例13: up

 function up()
 {
     // get the driver used
     \Config::load('auth', true);
     $drivers = \Config::get('auth.driver', array());
     is_array($drivers) or $drivers = array($drivers);
     if (in_array('Simpleauth', $drivers)) {
         // get the tablename
         \Config::load('simpleauth', true);
         $table = \Config::get('simpleauth.table_name', 'users');
         // only do this if it doesn't exist yet
         if (!\DBUtil::table_exists($table)) {
             // table users
             \DBUtil::create_table($table, array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50), 'password' => array('type' => 'varchar', 'constraint' => 255), 'group' => array('type' => 'int', 'constraint' => 11, 'default' => 1), 'email' => array('type' => 'varchar', 'constraint' => 255), 'last_login' => array('type' => 'varchar', 'constraint' => 25), 'login_hash' => array('type' => 'varchar', 'constraint' => 255), 'profile_fields' => array('type' => 'text'), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0)), array('id'));
             // add a unique index on username and email
             \DBUtil::create_index($table, array('username', 'email'), 'username', 'UNIQUE');
         }
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         if (!\DBUtil::table_exists($table)) {
             // get the simpleauth tablename, maybe that exists
             \Config::load('simpleauth', true);
             $simpletable = \Config::get('simpleauth.table_name', 'users');
             if (!\DBUtil::table_exists($simpletable)) {
                 // table users
                 \DBUtil::create_table($table, array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50), 'password' => array('type' => 'varchar', 'constraint' => 255), 'group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1), 'email' => array('type' => 'varchar', 'constraint' => 255), 'last_login' => array('type' => 'varchar', 'constraint' => 25), 'previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0), 'login_hash' => array('type' => 'varchar', 'constraint' => 255), 'user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0)), array('id'));
                 // add a unique index on username and email
                 \DBUtil::create_index($table, array('username', 'email'), 'username', 'UNIQUE');
             } else {
                 \DBUtil::rename_table($simpletable, $table);
             }
         }
         // run a check on required fields, and deal with missing ones. we might be migrating from simpleauth
         if (\DBUtil::field_exists($table, 'group')) {
             \DBUtil::modify_fields($table, array('group' => array('name' => 'group_id', 'type' => 'int', 'constraint' => 11)));
         }
         if (!\DBUtil::field_exists($table, 'group_id')) {
             \DBUtil::add_fields($table, array('group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1, 'after' => 'password')));
         }
         if (!\DBUtil::field_exists($table, 'previous_login')) {
             \DBUtil::add_fields($table, array('previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0, 'after' => 'last_login')));
         }
         if (!\DBUtil::field_exists($table, 'user_id')) {
             \DBUtil::add_fields($table, array('user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'login_hash')));
         }
         if (\DBUtil::field_exists($table, 'created')) {
             \DBUtil::modify_fields($table, array('created' => array('name' => 'created_at', 'type' => 'int', 'constraint' => 11)));
         }
         if (!\DBUtil::field_exists($table, 'created_at')) {
             \DBUtil::add_fields($table, array('created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'user_id')));
         }
         if (\DBUtil::field_exists($table, 'updated')) {
             \DBUtil::modify_fields($table, array('updated' => array('name' => 'updated_at', 'type' => 'int', 'constraint' => 11)));
         }
         if (!\DBUtil::field_exists($table, 'updated_at')) {
             \DBUtil::add_fields($table, array('updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'created_at')));
         }
         // table users_meta
         \DBUtil::create_table($table . '_metadata', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'parent_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'key' => array('type' => 'varchar', 'constraint' => 20), 'value' => array('type' => 'varchar', 'constraint' => 100), 'user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0)), array('id'));
         // convert profile fields to metadata, and drop the column
         if (\DBUtil::field_exists($table, 'profile_fields')) {
             $result = \DB::select('id', 'profile_fields')->from($table)->execute();
             foreach ($result as $row) {
                 $profile_fields = empty($row['profile_fields']) ? array() : unserialize($row['profile_fields']);
                 foreach ($profile_fields as $field => $value) {
                     if (!is_numeric($field)) {
                         \DB::insert($table . '_metadata')->set(array('parent_id' => $row['id'], 'key' => $field, 'value' => $value))->execute();
                     }
                 }
             }
             \DBUtil::drop_fields($table, array('profile_fields'));
         }
         // table users_user_role
         \DBUtil::create_table($table . '_user_roles', array('user_id' => array('type' => 'int', 'constraint' => 11), 'role_id' => array('type' => 'int', 'constraint' => 11)), array('user_id', 'role_id'));
         // table users_user_perms
         \DBUtil::create_table($table . '_user_permissions', array('user_id' => array('type' => 'int', 'constraint' => 11), 'perms_id' => array('type' => 'int', 'constraint' => 11)), array('user_id', 'perms_id'));
     }
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:80,代码来源:001_auth_create_usertables.php

示例14: action_accountMultisite

 public function action_accountMultisite()
 {
     $act = trim(\Input::post('act'));
     $output = [];
     if (strtolower(\Fuel\Core\Input::method()) == 'post') {
         if ($act == 'createmaintable') {
             $create_table = \Fuel\Core\DBUtil::create_table('testmultisiteaccount', ['id' => ['constraint' => 11, 'type' => 'int', 'auto_increment' => true], 'account_id' => ['constraint' => 11, 'type' => 'int', 'null' => true, 'comment' => 'refer to accounts.account_id'], 'actdate' => ['type' => 'bigint', 'null' => true, 'comment' => 'date/time of record date.']], ['id'], true);
             $output['create_table_result'] = $create_table;
             $output['result'] = true;
         } elseif ($act == 'insertdemodata') {
             // get accounts that is not guest
             $account_result = \DB::select('account_id')->as_object()->from('accounts')->where('account_id', '!=', '0')->execute();
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             $output['tables_data'] = [];
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         \DBUtil::truncate_table($test_table);
                         if ($account_result != null) {
                             foreach ($account_result as $account) {
                                 \DB::insert($test_table)->set(['account_id' => $account->account_id, 'actdate' => time()])->execute();
                             }
                             // endforeach; $account_result
                         }
                         // endif; $account_result
                         // finished insert get data from this table.
                         $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array();
                         $output['tables_data'][$test_table] = $this_table_result;
                         unset($this_table_result);
                     }
                     unset($test_table);
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($account, $account_result, $site, $sites_result);
         } elseif ($act == 'loaddemodata') {
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             $output['tables_data'] = [];
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array();
                         $output['tables_data'][$test_table] = $this_table_result;
                         unset($this_table_result);
                     }
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($site, $sites_result);
         } elseif ($act == 'droptable') {
             // get all sites from site table
             $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute();
             if ($sites_result != null) {
                 foreach ($sites_result as $site) {
                     if ($site->site_id == '1') {
                         $test_table = 'testmultisiteaccount';
                     } else {
                         $test_table = $site->site_id . '_testmultisiteaccount';
                     }
                     if (\DBUtil::table_exists($test_table)) {
                         \DBUtil::drop_table($test_table);
                     }
                 }
                 // endforeach; $sites_result
                 $output['result'] = true;
             }
             // endif; $sites_result
             unset($site, $sites_result);
         }
         // endif; $act
         if (\Input::is_ajax()) {
             $response = new \Response();
             // no cache
             $response->set_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
             $response->set_header('Cache-Control', 'post-check=0, pre-check=0', false);
             $response->set_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
             $response->set_header('Pragma', 'no-cache');
             // content type
             $response->set_header('Content-Type', 'application/json');
             // set body
             if ($output == null) {
                 $output = [];
             }
             $response->body(json_encode($output));
//.........这里部分代码省略.........
开发者ID:rundiz,项目名称:fuel-start,代码行数:101,代码来源:index.php

示例15: force_login

 public function force_login()
 {
     if (DBUtil::table_exists('v2_urls')) {
         if (DB::count_records('urls') < DB::count_records('v2_urls')) {
             \Controller_Migrate::migrate();
         }
     }
     if (Input::Method() === 'POST') {
         // call Auth to create this user
         $new_user = \Auth::create_user(Input::POST('username'), Input::POST('password'), Input::POST('email'), 5, array('fullname' => Input::POST('name')));
     } else {
         // call Auth to create this user
         $new_user = \Auth::create_user('meela', 'password', 'meela@mee.la', 5, array('fullname' => 'Meela Admin'));
     }
     $delete_users = Model_User::query()->where('username', 'admin')->or_where('username', 'guest')->get();
     foreach ($delete_users as $user) {
         $user->delete();
     }
     // if a user was created succesfully
     if ($new_user) {
         \Auth::force_login($new_user);
     }
     $file = DOCROOT . 'assets/url_stats_countries.csv';
     // Insert data into temporary table from file
     $query = 'LOAD DATA LOCAL INFILE "' . $file . '" INTO TABLE url_stats_countries fields terminated by "," enclosed by \'"\' lines terminated by "\\n" (id,start_ip,end_ip,country,created_at,updated_at)';
     \DB::query($query)->execute();
     Response::Redirect(Uri::Create('admin/settings'));
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:28,代码来源:install.php


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