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


PHP DBUtil::create_index方法代码示例

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


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

示例1: 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

示例2: up

 public function up()
 {
     \DBUtil::create_table('menu', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true), 'left_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'right_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'tree_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'name' => array('constraint' => 252, 'type' => 'varchar'), 'slug' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'url' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'fields' => array('type' => 'text', 'null' => true)), array('id'));
     \DBUtil::create_index('menu', 'left_id');
     \DBUtil::create_index('menu', 'right_id');
     \DBUtil::create_table('menu_meta', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'menu_id' => array('constraint' => 11, 'type' => 'int'), 'key' => array('type' => 'text'), 'value' => array('type' => 'text')), array('id'));
 }
开发者ID:indigophp,项目名称:fuel-menu,代码行数:7,代码来源:001_create_menu.php

示例3: 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') . '_providers';
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users') . '_providers';
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
     }
     if (isset($table)) {
         \DBUtil::create_table($table, array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'parent_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'provider' => array('type' => 'varchar', 'constraint' => 50), 'uid' => array('type' => 'varchar', 'constraint' => 255), 'secret' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'access_token' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'expires' => array('type' => 'int', 'constraint' => 12, 'default' => 0, 'null' => true), 'refresh_token' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), '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'));
         \DBUtil::create_index($table, 'parent_id', 'parent_id');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:26,代码来源:008_auth_create_providers.php

示例4: up

 function up()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Simpleauth', $drivers)) {
         // get the tablename
         \Config::load('simpleauth', true);
         $basetable = \Config::get('simpleauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $basetable = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
     } else {
         $basetable = 'users';
     }
     \DBUtil::create_table($basetable . '_clients', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'name' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'client_id' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'client_secret' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'redirect_uri' => array('type' => 'varchar', 'constraint' => 255, 'default' => ''), 'auto_approve' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'autonomous' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'status' => array('type' => 'enum', 'constraint' => '"development","pending","approved","rejected"', 'default' => 'development'), 'suspended' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'notes' => array('type' => 'tinytext')), array('id'));
     \DBUtil::create_index($basetable . '_clients', 'client_id', 'client_id', 'UNIQUE');
     \DBUtil::create_table($basetable . '_sessions', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'client_id' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'redirect_uri' => array('type' => 'varchar', 'constraint' => 255, 'default' => ''), 'type_id' => array('type' => 'varchar', 'constraint' => 64), 'type' => array('type' => 'enum', 'constraint' => '"user","auto"', 'default' => 'user'), 'code' => array('type' => 'text'), 'access_token' => array('type' => 'varchar', 'constraint' => 50, 'default' => ''), 'stage' => array('type' => 'enum', 'constraint' => '"request","granted"', 'default' => 'request'), 'first_requested' => array('type' => 'int', 'constraint' => 11), 'last_updated' => array('type' => 'int', 'constraint' => 11), 'limited_access' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0)), array('id'), true, false, null, array(array('constraint' => 'oauth_sessions_ibfk_1', 'key' => 'client_id', 'reference' => array('table' => $basetable . '_clients', 'column' => 'client_id'), 'on_delete' => 'CASCADE')));
     \DBUtil::create_table($basetable . '_scopes', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'scope' => array('type' => 'varchar', 'constraint' => 64, 'default' => ''), 'name' => array('type' => 'varchar', 'constraint' => 64, 'default' => ''), 'description' => array('type' => 'varchar', 'constraint' => 255, 'default' => '')), array('id'));
     \DBUtil::create_index($basetable . '_scopes', 'scope', 'scope', 'UNIQUE');
     \DBUtil::create_table($basetable . '_sessionscopes', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'session_id' => array('type' => 'int', 'constraint' => 11), 'access_token' => array('type' => 'varchar', 'constraint' => 50, 'default' => ''), 'scope' => array('type' => 'varchar', 'constraint' => 64, 'default' => '')), array('id'), true, false, null, array(array('constraint' => 'oauth_sessionscopes_ibfk_1', 'key' => 'scope', 'reference' => array('table' => $basetable . '_scopes', 'column' => 'scope')), array('constraint' => 'oauth_sessionscopes_ibfk_2', 'key' => 'session_id', 'reference' => array('table' => $basetable . '_sessions', 'column' => 'id'), 'on_delete' => 'CASCADE')));
     \DBUtil::create_index($basetable . '_sessionscopes', 'session_id', 'session_id');
     \DBUtil::create_index($basetable . '_sessionscopes', 'access_token', 'access_token');
     \DBUtil::create_index($basetable . '_sessionscopes', 'scope', 'scope');
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:31,代码来源:009_auth_create_oauth2tables.php

示例5: up

 public function up()
 {
     \DBUtil::create_table('statistics', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'seller_id' => array('type' => 'int', 'constraint' => 11), 'type' => array('type' => 'varchar', 'constraint' => 50), 'name' => array('type' => 'varchar', 'constraint' => 255), 'value' => array('type' => 'text'), 'date' => array('type' => 'date')), array('id'));
     \DBUtil::create_index('statistics', 'seller_id', 'seller_id');
     \DBUtil::create_index('statistics', array('seller_id', 'type'), 'seller_type');
     \DBUtil::create_index('statistics', array('seller_id', 'type', 'name'), 'seller_type_name');
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:7,代码来源:019_create_statistics.php

示例6: up

 public function up()
 {
     \DBUtil::create_table('customer_gateways', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'customer_id' => array('type' => 'int', 'constraint' => 11), 'gateway_id' => array('type' => 'int', 'constraint' => 11), 'external_id' => array('type' => 'varchar', 'constraint' => 255, 'null' => true)), array('id'));
     \DBUtil::create_index('customer_gateways', 'customer_id', 'customer_id');
     \DBUtil::create_index('customer_gateways', 'gateway_id', 'gateway_id');
     \DBUtil::create_index('customer_gateways', array('customer_id', 'gateway_id'), 'customer_gateway', 'unique');
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:7,代码来源:013_create_customer_gateways.php

示例7: up

 function up()
 {
     // get the configured table name
     $table = \Config::get('simpleauth.table_name', 'users');
     // 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)), array('id'));
     // add a unique index on username and email
     \DBUtil::create_index('users', array('username', 'email'), 'username', 'UNIQUE');
 }
开发者ID:wushian,项目名称:MDD,代码行数:9,代码来源:001_auth_create_simpleauth_table.php

示例8: 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

示例9: up

 public function up()
 {
     // For optimizing relations
     \DBUtil::create_index('comments', 'post_id');
     \DBUtil::create_index('posts', 'category_id');
     \DBUtil::create_index('posts', 'user_id');
     // For optimizing slug retrieval
     \DBUtil::create_index('posts', 'slug');
     \DBUtil::create_index('categories', 'slug');
 }
开发者ID:vano00,项目名称:blog,代码行数:10,代码来源:004_create_indexes.php

示例10: up

    public function up()
    {
        /*         * *********************************************************************************************
                  monitor_type
                 * ********************************************************************************************* */
        $monitor_type = \DBUtil::checkIfExist('monitor_type');
        if (!$monitor_type) {
            \DBUtil::create_table('monitor_type', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 250, 'type' => 'varchar')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            \DBUtil::truncate_table('monitor_type');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('monitor_type')->columns(array('id', 'name'))->values(array('1', 'Nagios'))->execute();
        }
        /*         * *********************************************************************************************
                  monitor_source
                 * ********************************************************************************************* */
        $monitor_source = \DBUtil::checkIfExist('monitor_source');
        if (!$monitor_source) {
            \DBUtil::create_table('monitor_source', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'typeID' => array('constraint' => 11, 'type' => 'int'), 'user' => array('constraint' => 250, 'type' => 'varchar'), 'pass' => array('constraint' => 250, 'type' => 'varchar'), 'content' => array('type' => 'text', 'null' => true), 'meta_update_time' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for wiki
            \DBUtil::create_index('monitor_source', 'typeID');
        }
        /*         * *********************************************************************************************
                  monitoring
                 * ********************************************************************************************* */
        $monitoring = \DBUtil::checkIfExist('monitoring');
        if (!$monitoring) {
            \DBUtil::create_table('monitoring', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'iconw' => array('constraint' => 11, 'type' => 'int'), 'iconu' => array('constraint' => 11, 'type' => 'int'), 'iconc' => array('constraint' => 11, 'type' => 'int'), 'osdw' => array('constraint' => 11, 'type' => 'int'), 'osdu' => array('constraint' => 11, 'type' => 'int'), 'osdc' => array('constraint' => 11, 'type' => 'int'), 'soundc' => array('constraint' => 11, 'type' => 'int'), 'soundw' => array('constraint' => 11, 'type' => 'int'), 'soundu' => array('constraint' => 11, 'type' => 'int'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for wiki
            //\DBUtil::create_index('vps', 'masterID');
            \DBUtil::truncate_table('monitoring');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('monitoring')->columns(array('id', 'iconw', 'iconu', 'iconc', 'osdw', 'osdu', 'osdc', 'soundc', 'soundw', 'soundu', 'meta_update_user'))->values(array('1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'))->execute();
        }
        /*         * *********************************************************************************************
                  FOREIGN KEYS
                 * ********************************************************************************************* */
        //monitor
        if (!$monitor_source) {
            $query = \DB::query('ALTER TABLE `monitor_source`
				ADD CONSTRAINT `monitor_ibfk_1` FOREIGN KEY (`typeID`) REFERENCES `monitor_type` (`id`) 
				ON DELETE CASCADE ON UPDATE CASCADE')->execute();
        }
        /*
         * UPDATE version 
         * 
         * */
        $now = time();
        list($insert_id, $rows_affected) = \DB::insert('version')->columns(array('value', 'meta_update_time'))->values(array('1.08', $now))->execute();
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:49,代码来源:001_installmon.php

示例11: 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('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         // table users_perms
         \DBUtil::create_table($table . '_permissions', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'area' => array('type' => 'varchar', 'constraint' => 25), 'permission' => array('type' => 'varchar', 'constraint' => 25), 'description' => 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 group and permission
         \DBUtil::create_index($table . '_permissions', array('area', 'permission'), 'permission', 'UNIQUE');
     }
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:16,代码来源:004_auth_create_permissiontables.php

示例12: up

 function up()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
         // table users_perms
         \DBUtil::create_table($table . '_permissions', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'area' => array('type' => 'varchar', 'constraint' => 25), 'permission' => array('type' => 'varchar', 'constraint' => 25), 'description' => 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 group and permission
         \DBUtil::create_index($table . '_permissions', array('area', 'permission'), 'permission', 'UNIQUE');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:18,代码来源:004_auth_create_permissiontables.php

示例13: up

    public function up()
    {
        /*         * *********************************************************************************************
                  munin
                 * ********************************************************************************************* */
        $munin = \DBUtil::checkIfExist('munin');
        if (!$munin) {
            \DBUtil::create_table('munin', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'url' => array('constraint' => 250, 'type' => 'varchar'), 'deviceID' => array('constraint' => 11, 'type' => 'int'), 'user' => array('constraint' => 250, 'type' => 'varchar'), 'pass' => array('constraint' => 250, 'type' => 'varchar'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for graphing
            \DBUtil::create_index('munin', 'deviceID');
        }
        //graphing
        if (!$munin) {
            $query = \DB::query('ALTER TABLE `munin`
					ADD CONSTRAINT `munin_ibfk_1` FOREIGN KEY (`deviceID`) REFERENCES `device` (`id`)
					ON DELETE CASCADE ON UPDATE CASCADE')->execute();
        }
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:18,代码来源:002_installmunin.php

示例14: down

 function down()
 {
     // get the driver used
     \Config::load('auth', true);
     $drivers = \Config::get('auth.driver', array());
     is_array($drivers) or $drivers = array($drivers);
     if (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $basetable = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
         \DBUtil::drop_fields($basetable . '_user_permissions', array('id'));
         \DBUtil::create_index($basetable . '_user_permissions', array('user_id', 'perms_id'), '', 'PRIMARY');
         \DBUtil::drop_fields($basetable . '_group_permissions', array('id'));
         \DBUtil::create_index($basetable . '_group_permissions', array('group_id', 'perms_id'), '', 'PRIMARY');
         \DBUtil::drop_fields($basetable . '_role_permissions', array('id'));
         \DBUtil::create_index($basetable . '_role_permissions', array('role_id', 'perms_id'), '', 'PRIMARY');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:22,代码来源:010_auth_fix_jointables.php

示例15: 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


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