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


PHP DBUtil::truncate_table方法代码示例

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


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

示例1: index

 /**
  * This method gets ran when a valid method name is not used in the command.
  *
  * Usage (from command line):
  *
  * php oil r setuptables:index "arguments"
  *
  * @return string
  */
 public function index($args = NULL)
 {
     echo "\n===========================================";
     echo "\nRunning task [Setuptables:Index]";
     echo "\n-------------------------------------------\n\n";
     /***************************
     		 Put in TASK DETAILS HERE
     		 **************************/
     // 初期ユーザー定義
     $init_users = array(array('name' => 'codex', 'password' => '1234', 'group' => 6));
     // データベース接続
     \DBUtil::set_connection(null);
     // {{{ トランケート
     $truncates = array('', '_permissions', '_metadata', '_user_permissions', '_group_permissions', '_role_permissions');
     foreach ($truncates as $truncate) {
         \DBUtil::truncate_table('users' . $truncate);
     }
     // }}}
     // {{{ 初期ユーザー追加
     foreach ($init_users as $init_user) {
         // ユーザー名
         $key = $init_user['name'];
         // パスワード
         $password = $init_user['password'];
         // メールアドレス
         $email = $key . '@xenophy.com';
         // グループ
         $group = $init_user['group'];
         // 追加
         $user = \Auth\Model\Auth_User::forge()->find(\Auth::create_user($key, $password, $email, $group));
         // 保存
         $user->save();
     }
     // }}}
 }
开发者ID:xenophy,项目名称:code-x,代码行数:44,代码来源:setuptables.php

示例2: down

 public function down()
 {
     \DBUtil::truncate_table('location');
     \DBUtil::truncate_table('events');
     \DBUtil::truncate_table('agenda');
     \DBUtil::truncate_table('countries');
     \DBUtil::truncate_table('users');
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:8,代码来源:002_demo_data.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: action_openid_reset

 public function action_openid_reset()
 {
     \DBUtil::truncate_table('users_openid');
     $auth = Auth::instance();
     echo '<p>' . $auth->create_user($group = 100) . '</p>';
     echo '<p>' . $auth->create_user($group = 1) . '</p>';
     echo '<p>' . $auth->create_user($group = 0) . '</p>';
     echo 'done';
 }
开发者ID:huglester,项目名称:fuel-GasCap,代码行数:9,代码来源:auth.php

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

示例6: 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);
         $table = \Config::get('ormauth.table_name', 'users');
         // empty the user, group and role tables
         \DBUtil::truncate_table($table);
         \DBUtil::truncate_table($table . '_groups');
         \DBUtil::truncate_table($table . '_roles');
         \DBUtil::truncate_table($table . '_group_roles');
     }
 }
开发者ID:cloudetm,项目名称:development,代码行数:17,代码来源:005_auth_create_authdefaults.php

示例7: down

 function down()
 {
     // 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));
         // empty the user, group and role tables
         \DBUtil::truncate_table($table);
         \DBUtil::truncate_table($table . '_groups');
         \DBUtil::truncate_table($table . '_roles');
         \DBUtil::truncate_table($table . '_group_roles');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:19,代码来源:005_auth_create_authdefaults.php

示例8: action_delete_log

 public function action_delete_log($account_id = '')
 {
     // clear redirect referrer
     \Session::delete('submitted_redirect');
     // set redirect url
     $redirect = $this->getAndSetSubmitRedirection();
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('account_perm', 'account_deletelogin_log_perm') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         \Response::redirect($redirect);
     }
     if (!is_numeric($account_id)) {
         \Response::redirect($redirect);
     }
     // load language
     \Lang::load('account');
     \Lang::load('accountlogins');
     $act = trim(\Input::post('act'));
     if (\Extension\NoCsrf::check()) {
         // if actions
         if ($act == 'del') {
             \Model_AccountLogins::query()->where('account_id', $account_id)->delete();
         } elseif ($act == 'truncate') {
             \DBUtil::truncate_table('account_logins');
         }
     }
     // go back
     \Response::redirect($redirect);
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:29,代码来源:account.php

示例9: down

 public function down()
 {
     \DBUtil::truncate_table($this->table_name);
 }
开发者ID:ratiw,项目名称:petro-test,代码行数:4,代码来源:115_insert_menus_data.php

示例10: up

    function up()
    {
        $user = \DB::select('id')->from('users')->limit(1)->execute()->current();
        /*         * *********************************************************************************************
                  building
                 * ********************************************************************************************* */
        $building = \DBUtil::checkIfExist('building');
        if (!$building) {
            \DBUtil::create_table('building', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 250, 'type' => 'varchar'), 'name_short' => array('constraint' => 250, 'type' => 'varchar', 'null' => true), 'notes' => array('type' => 'text', 'null' => true), 'meta_default_data' => array('constraint' => 11, 'type' => 'int', 'null' => true, 'default' => '0'), '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');
            // insert default building
            list($building_id, $rows_affected) = \DB::insert('building')->columns(array('id', 'name', 'name_short', 'notes', 'meta_default_data', 'meta_update_time', 'meta_update_user'))->values(array('1', 'Building Demo', '', '', '', time(), $user['id']))->execute();
        }
        /*         * *********************************************************************************************
                  cables
                 * ********************************************************************************************* */
        $cables = \DBUtil::checkIfExist('cables');
        if (!$cables) {
            \DBUtil::create_table('cables', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'dev1' => array('constraint' => 11, 'type' => 'int'), 'port1' => array('constraint' => 11, 'type' => 'int'), 'name1' => array('constraint' => 4, 'type' => 'int'), 'dev2' => array('constraint' => 11, 'type' => 'int'), 'port2' => array('constraint' => 11, 'type' => 'int'), 'name2' => array('constraint' => 4, 'type' => 'int'), 'type' => array('constraint' => 11, 'type' => 'int'), '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 cable devices
            \DBUtil::create_index('cables', 'dev1');
            \DBUtil::create_index('cables', 'dev2');
        }
        /*         * *********************************************************************************************
                  connector speed
                 * ********************************************************************************************* */
        $connector_speed = \DBUtil::checkIfExist('connector_speed');
        if (!$connector_speed) {
            \DBUtil::create_table('connector_speed', 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('connector_speed');
            // insert default connector speed
            list($insert_id, $rows_affected) = \DB::insert('connector_speed')->columns(array('id', 'name'))->values(array('1', '10 MBs'), array('2', '10/100 MBs'), array('3', '1 GBs'), array('4', '10 GBs'))->execute();
        }
        /*         * *********************************************************************************************
                  connector type
                 * ********************************************************************************************* */
        $connector_type = \DBUtil::checkIfExist('connector_type');
        if (!$connector_type) {
            \DBUtil::create_table('connector_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('connector_type');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('connector_type')->columns(array('id', 'name'))->values(array('1', 'RJ45'), array('2', 'Fiber LC'))->execute();
        }
        /*         * *********************************************************************************************
                  device
                 * ********************************************************************************************* */
        $device = \DBUtil::checkIfExist('device');
        if (!$device) {
            \DBUtil::create_table('device', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'hostname' => array('constraint' => 250, 'type' => 'varchar'), 'type' => array('constraint' => 11, 'type' => 'int'), 'cat' => array('constraint' => 11, 'type' => 'int'), 'rack' => array('constraint' => 11, 'type' => 'int'), 'rack_pos' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'rack_units' => array('constraint' => 11, 'type' => 'int', 'default' => '1'), 'parent_device' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'meta_default_data' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), '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 device
            \DBUtil::create_index('device', 'type');
            \DBUtil::create_index('device', 'cat');
            \DBUtil::create_index('device', 'rack');
        }
        /*         * *********************************************************************************************
                  device category
                 * ********************************************************************************************* */
        $device_category = \DBUtil::checkIfExist('device_category');
        if (!$device_category) {
            \DBUtil::create_table('device_category', 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('device_category');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('device_category')->columns(array('id', 'name'))->values(array('1', 'Server'), array('2', 'Switch'), array('3', 'Router'), array('4', 'PDU'), array('5', 'Patch Panel'), array('6', 'KVM Switch'), array('7', 'APC ATS'), array('8', 'FC Switch'), array('9', 'Human Interface'), array('10', 'UPS'))->execute();
        }
        /*         * *********************************************************************************************
                  device fieldset
                 * ********************************************************************************************* */
        $device_fieldset = \DBUtil::checkIfExist('device_fieldset');
        if (!$device_fieldset) {
            \DBUtil::create_table('device_fieldset', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 250, 'type' => 'varchar'), 'type' => array('constraint' => 250, 'type' => 'varchar'), 'deviceID' => array('constraint' => 11, 'type' => 'int'), 'tab' => array('constraint' => 11, 'type' => 'int'), 'value' => array('type' => 'text', 'null' => true), 'extra' => array('constraint' => 250, 'type' => 'varchar', 'null' => true), 'static' => array('constraint' => 1, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for device
            \DBUtil::create_index('device_fieldset', 'deviceID');
            //\DBUtil::create_index('device_fieldset',array('name','type','deviceID'),'un_key_field','unique');
        }
        /*         * *********************************************************************************************
                  device KVM
                 * ********************************************************************************************* */
        $device_kvm = \DBUtil::checkIfExist('device_kvm');
        if (!$device_kvm) {
            \DBUtil::create_table('device_kvm', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'fieldsetID' => array('constraint' => 11, 'type' => 'int'), 'deviceID' => array('constraint' => 11, 'type' => 'int'), 'input' => array('constraint' => 11, 'type' => 'int'), 'output' => array('constraint' => 11, 'type' => 'int'), 'type' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for device kvm
            \DBUtil::create_index('device_kvm', 'fieldsetID');
            \DBUtil::create_index('device_kvm', 'deviceID');
        }
        /*         * *********************************************************************************************
                  device KVM socket
                 * ********************************************************************************************* */
        $device_kvm_socket = \DBUtil::checkIfExist('device_kvm_socket');
        if (!$device_kvm_socket) {
            \DBUtil::create_table('device_kvm_socket', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'kvmID' => array('constraint' => 11, 'type' => 'int'), 'conn_type' => array('constraint' => 11, 'type' => 'int'), 'type' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for device kvm socket
            \DBUtil::create_index('device_kvm_socket', 'kvmID');
        }
        /*         * *********************************************************************************************
                  device network
                 * ********************************************************************************************* */
        $device_network = \DBUtil::checkIfExist('device_network');
        if (!$device_network) {
            \DBUtil::create_table('device_network', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'fieldsetID' => array('constraint' => 11, 'type' => 'int'), 'deviceID' => array('constraint' => 11, 'type' => 'int'), 'nics' => array('constraint' => 11, 'type' => 'int'), 'vports' => array('constraint' => 11, 'type' => 'int'), 'ports' => array('constraint' => 11, 'type' => 'int'), 'uplinks' => array('constraint' => 11, 'type' => 'int'), 'config_data' => array('type' => 'text'), 'type' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for device network
            \DBUtil::create_index('device_network', 'fieldsetID');
//.........这里部分代码省略.........
开发者ID:quickpacket,项目名称:noclayer,代码行数:101,代码来源:001_install.php

示例11: down

 public function down()
 {
     \DBUtil::truncate_table('clients');
 }
开发者ID:ratiw,项目名称:petro-test,代码行数:4,代码来源:103_insert_clients_data.php

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

示例13: truncate

 public static function truncate()
 {
     try {
         return \DBUtil::truncate_table(static::$_table_name);
     } catch (\Database_Exception $e) {
         return false;
     }
 }
开发者ID:khoapossible,项目名称:vision_system,代码行数:8,代码来源:advanced.php

示例14: down

 public function down()
 {
     \DBUtil::truncate_table(\Config::get('sentry.table.users'));
     \DBUtil::truncate_table(\Config::get('sentry.table.groups'));
 }
开发者ID:ratiw,项目名称:petro-test,代码行数:5,代码来源:003_insert_sentry_testdata.php

示例15: up

    public function up()
    {
        /*         * *********************************************************************************************
                  graphing
                 * ********************************************************************************************* */
        $graphing = \DBUtil::checkIfExist('graphing');
        if (!$graphing) {
            \DBUtil::create_table('graphing', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 250, 'type' => 'varchar'), 'value' => array('constraint' => 250, 'type' => 'varchar'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            \DBUtil::truncate_table('graphing');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('graphing')->columns(array('id', 'name', 'value', 'meta_update_user'))->values(array('1', 'cacti_size', '1', '1'))->execute();
        }
        /*         * *********************************************************************************************
                  graphing_type
                 * ********************************************************************************************* */
        $graphing_type = \DBUtil::checkIfExist('graphing_type');
        if (!$graphing_type) {
            \DBUtil::create_table('graphing_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('graphing_type');
            // insert default connector type
            list($insert_id, $rows_affected) = \DB::insert('graphing_type')->columns(array('id', 'name'))->values(array('1', 'Cacti'))->execute();
        }
        /*         * *********************************************************************************************
                  graphing_source
                 * ********************************************************************************************* */
        $graphing_source = \DBUtil::checkIfExist('graphing_source');
        if (!$graphing_source) {
            \DBUtil::create_table('graphing_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 graphing
            \DBUtil::create_index('graphing_source', 'typeID');
        }
        /*         * *********************************************************************************************
                  graphing_cacti
                 * ********************************************************************************************* */
        $graphing_cacti = \DBUtil::checkIfExist('graphing_cacti');
        if (!$graphing_cacti) {
            \DBUtil::create_table('graphing_cacti', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'sourceID' => array('constraint' => 11, 'type' => 'int'), 'name' => array('constraint' => 250, 'type' => 'varchar'), 'num' => array('constraint' => 250, 'type' => 'varchar'), 'macID' => array('constraint' => 11, 'type' => 'int'), 'graphID' => array('constraint' => 11, 'type' => 'int'), 'meta_update_time' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'deviceID' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for graphing
            \DBUtil::create_index('graphing_cacti', 'deviceID');
            \DBUtil::create_index('graphing_cacti', 'sourceID');
            \DBUtil::create_index('graphing_cacti', 'macID');
        }
        /*         * *********************************************************************************************
                  FOREIGN KEYS
                 * ********************************************************************************************* */
        //graphing
        if (!$graphing_source) {
            $query = \DB::query('ALTER TABLE `graphing_source`
					ADD CONSTRAINT `graphing_ibfk_1` FOREIGN KEY (`typeID`) REFERENCES `graphing_type` (`id`)
					ON DELETE CASCADE ON UPDATE CASCADE')->execute();
        }
        //graphing_cacti
        if (!$graphing_cacti) {
            $query = \DB::query('ALTER TABLE `graphing_cacti`
					ADD CONSTRAINT `graphing_cacti_ibfk_1` FOREIGN KEY (`sourceID`) REFERENCES `graphing_source` (`id`)
					ON DELETE CASCADE ON UPDATE CASCADE')->execute();
            /*
             $query = \DB::query('ALTER TABLE `graphing_cacti`
             ADD CONSTRAINT `graphing_cacti_ibfk_2` FOREIGN KEY (`macID`) REFERENCES `network_mac_ports` (`id`)
             ON DELETE CASCADE ON UPDATE CASCADE')->execute();
            */
            $query = \DB::query('ALTER TABLE `graphing_cacti`
					ADD CONSTRAINT `graphing_cacti_ibfk_3` FOREIGN KEY (`deviceID`) REFERENCES `device` (`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.09', $now))->execute();
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:72,代码来源:001_installgraph.php


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