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


PHP DBUtil::checkIfExist方法代码示例

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


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

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

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

示例3: up

 public function up()
 {
     $user = \DB::select('id')->from('users')->limit(1)->execute()->current();
     /*         * ********************************************************************************************
               update rack position
              * ********************************************************************************************* */
     $israck = \DBUtil::checkIfExist('rack');
     if ($israck) {
         if (!\DBUtil::field_exists('rack', array('position'))) {
             // Fields don't exist
             \DBUtil::add_fields('rack', array('position' => array('constraint' => 11, 'type' => 'int')));
         }
     }
     /*         * ********************************************************************************************
               add room height to settings
              * ********************************************************************************************* */
     $settings = \DB::select('value')->from('settings')->where('name', 'room_height')->as_object()->execute();
     if (!isset($settings[0])) {
         // insert default building
         list($set_id, $rows_affected) = \DB::insert('settings')->columns(array('id', 'name', 'value', 'meta_update_user'))->values(array('', 'room_height', '2500', $user['id']))->execute();
     }
     $settings = \DB::select('value')->from('settings')->where('name', 'tutorials')->as_object()->execute();
     if (!isset($settings[0])) {
         // insert default building
         list($set_id, $rows_affected) = \DB::insert('settings')->columns(array('id', 'name', 'value', 'meta_update_user'))->values(array('', 'tutorials', '0', $user['id']))->execute();
     }
     $settings = \DB::select('value')->from('settings')->where('name', 'background')->as_object()->execute();
     if (!isset($settings[0])) {
         // insert default building
         list($set_id, $rows_affected) = \DB::insert('settings')->columns(array('id', 'name', 'value', 'meta_update_user'))->values(array('', 'background', '2', $user['id']))->execute();
     }
     /*         * ********************************************************************************************
               fix zero position for racks into rooms
              * ********************************************************************************************* */
     $this->__update_rack_position();
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:36,代码来源:004_upgraderacks.php

示例4: Network_Ip

 public static function Network_Ip($model, $method)
 {
     $ipm_history = \DBUtil::checkIfExist('ipm_history');
     if ($ipm_history) {
         if ($method == 'before_delete') {
             $ipv4 = new Ipv4object($model->ipv4);
             $ipv4Int = $ipv4->toInt();
             if ($ipv4Int > 0) {
                 $q = array('ip_dotted' => $model->ipv4, 'ip_int' => $ipv4Int, 'time' => time(), 'device' => 0, 'devname' => '', 'user' => 1);
                 $history = new \Ipm\Model_History($q);
                 $history->save();
             }
         }
         if ($method == 'before_save') {
             $oldipv4 = '';
             $old_data = \DB::select('ipv4')->from('network_ip_ports')->where('id', $model->id)->as_object()->execute();
             if (count($old_data) > 0) {
                 $oldipv4 = $old_data[0]->ipv4;
             }
             if (strlen($model->ipv4) > 0) {
                 $ipv4 = new Ipv4object($model->ipv4);
                 $ipv4Int = $ipv4->toInt();
                 $device = $model->network->device->id;
                 $hist = \Ipm\Model_History::find('last');
                 $up = true;
                 if ($hist) {
                     if ($hist['ip_int'] == $ipv4Int and $hist['device'] == $device) {
                         $up = false;
                     }
                 }
                 //update new location for ip
                 if ($up) {
                     $q = array('ip_dotted' => $model->ipv4, 'ip_int' => $ipv4Int, 'time' => time(), 'device' => $device, 'devname' => $model->network->device->hostname, 'user' => 1);
                     $history = new \Ipm\Model_History($q);
                     $history->save();
                 }
                 if (strlen($oldipv4) > 0) {
                     //set old ip to undefined(device = 0)
                     if ($oldipv4 != $model->ipv4) {
                         $ipv42 = new Ipv4object($oldipv4);
                         $ipv4Int2 = $ipv42->toInt();
                         $q = array('ip_dotted' => $oldipv4, 'ip_int' => $ipv4Int2, 'time' => time(), 'device' => 0, 'devname' => '', 'user' => 1);
                         $history2 = new \Ipm\Model_History($q);
                         $history2->save();
                     }
                 }
             }
         }
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:50,代码来源:observer.php

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

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

示例7: up

    public function up()
    {
        //make subnets
        /*         * *********************************************************************************************
                  vps ports
                 * ********************************************************************************************* */
        $vps_ports = \DBUtil::checkIfExist('vps_ports');
        if (!$vps_ports) {
            \DBUtil::create_table('vps_ports', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'vpsID' => array('constraint' => 11, 'type' => 'int'), 'portID' => array('constraint' => 11, 'type' => 'int'), 'type' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
            //create indexes for wiki
            \DBUtil::create_index('vps_ports', 'vpsID');
            \DBUtil::create_index('vps_ports', 'portID');
        }
        //ips of vps
        if (!$vps_ports) {
            $query = \DB::query('ALTER TABLE `vps_ports`
					ADD CONSTRAINT `vps_ip__portibfk_1` FOREIGN KEY (`vpsID`) REFERENCES `vps` (`id`)
					ON DELETE CASCADE ON UPDATE CASCADE')->execute();
        }
        //$this->parse_vps_address();
        /*         * *********************************************************************************************
                  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');
                  }
        
                 */
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:43,代码来源:003_vpsset.php

示例8: up

 public function up()
 {
     /*         * *********************************************************************************************
               ipm_subnet
              * ********************************************************************************************* */
     $ipm_subnet = \DBUtil::checkIfExist('ipm_subnet');
     if (!$ipm_subnet) {
         \DBUtil::create_table('ipm_subnet', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'subnet' => array('constraint' => 250, 'type' => 'varchar'), 'alias' => array('constraint' => 250, 'type' => 'varchar'), 'size' => array('constraint' => 11, 'type' => 'int'), 'mask' => array('constraint' => 50, 'type' => 'varchar'), 'description' => array('type' => 'text', 'null' => true), 'vlan' => array('constraint' => 11, 'type' => 'int', 'null' => true), 'type' => array('constraint' => 11, 'type' => 'int', 'null' => true), 'parent' => array('constraint' => 11, 'type' => 'int'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int'), 'range_from' => array('type' => 'double'), 'range_to' => array('type' => 'double')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
     }
     /*         * *********************************************************************************************
               ipm_node
              * ********************************************************************************************* */
     $ipm_node = \DBUtil::checkIfExist('ipm_node');
     if (!$ipm_node) {
         \DBUtil::create_table('ipm_node', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 250, 'type' => 'varchar'), 'parent' => array('constraint' => 11, 'type' => 'int'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
     }
     /*         * *********************************************************************************************
               ipm_location
              * ********************************************************************************************* */
     $ipm_location = \DBUtil::checkIfExist('ipm_location');
     if (!$ipm_location) {
         \DBUtil::create_table('ipm_location', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'node' => array('constraint' => 11, 'type' => 'int'), 'type' => array('constraint' => 11, 'type' => 'int'), 'building' => array('constraint' => 11, 'type' => 'int'), 'floor' => array('constraint' => 11, 'type' => 'int'), 'room' => array('constraint' => 11, 'type' => 'int'), 'rack' => array('constraint' => 11, 'type' => 'int'), 'pos_from' => array('constraint' => 11, 'type' => 'int'), 'pos_to' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
         //create indexes for location
         \DBUtil::create_index('ipm_location', 'node');
         \DBUtil::create_index('ipm_location', 'building');
         \DBUtil::create_index('ipm_location', 'floor');
         \DBUtil::create_index('ipm_location', 'room');
         \DBUtil::create_index('ipm_location', 'rack');
     }
     /*         * *********************************************************************************************
               ipm_history
              * ********************************************************************************************* */
     $ipm_history = \DBUtil::checkIfExist('ipm_history');
     if (!$ipm_history) {
         \DBUtil::create_table('ipm_history', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'ip_dotted' => array('constraint' => 16, 'type' => 'varchar'), 'ip_int' => array('type' => 'double'), 'time' => array('constraint' => 11, 'type' => 'int'), 'device' => array('constraint' => 11, 'type' => 'int'), 'devname' => array('constraint' => 220, 'type' => 'varchar', 'null' => true), 'user' => array('constraint' => 11, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
         //create indexes for location
         \DBUtil::create_index('ipm_history', 'device');
         \DBUtil::create_index('ipm_history', 'ip_int');
     }
     //make subnets
     $this->updateIpv4();
     /*         * *********************************************************************************************
               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');
               }
     
              */
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:64,代码来源:001_installipm.php

示例9: __erase_old_migration

 /**
  * old version < 1.09 is without modules.. erase old table and set new
  */
 private function __erase_old_migration()
 {
     \Config::load('install', true);
     $version = \Config::get('install.version');
     $table = \DBUtil::checkIfExist('version');
     if ($table) {
         if (!DBUtil::field_exists('version', array('mode'))) {
             // Fields dont exist
             \DBUtil::truncate_table('version');
             \DBUtil::add_fields('version', array('lastcheck' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'mode' => array('constraint' => 22, 'type' => 'varchar'), 'master' => array('constraint' => 22, 'type' => 'varchar'), 'quiet' => array('constraint' => 2, 'type' => 'int', 'default' => '0')));
             $now = time();
             /*  
                            \Config::load('update', true);
                             $master = \Config::get('update.version');
             */
             $master = '1.1';
             list($insert_id, $rows_affected) = \DB::insert('version')->columns(array('id', 'value', 'meta_update_time', 'lastcheck', 'mode', 'master', 'quiet'))->values(array('1', $master, $now, $now, $master, $master, 0))->execute();
             $table = \DBUtil::checkIfExist('simple_log');
             if (!$table) {
                 \DBUtil::create_table('simple_log', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'value' => array('type' => 'text')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
             }
         }
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:27,代码来源:installbasic.php

示例10: up

 function up()
 {
     /***********************************************************************************************
     		 groups
     		***********************************************************************************************/
     $groups = \DBUtil::checkIfExist('groups');
     if (!$groups) {
         \DBUtil::create_table('groups', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'level' => array('constraint' => 11, 'type' => 'int'), 'is_admin' => array('constraint' => 1, 'type' => 'int')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
     }
     /***********************************************************************************************
     		 migration
     		***********************************************************************************************/
     $migration = \DBUtil::checkIfExist('migration');
     if (!$migration) {
         \DBUtil::create_table('migration', array('name' => array('constraint' => 50, 'type' => 'varchar'), 'type' => array('constraint' => 25, 'type' => 'varchar'), 'version' => array('constraint' => 11, 'type' => 'int')), array(), true, 'InnoDB', 'utf8_unicode_ci');
         // insert default connector type
         //\DBUtil::truncate_table('migration');
         list($insert_id, $rows_affected) = \DB::insert('migration')->columns(array('name', 'type', 'version'))->values(array('sentry', 'package', 1))->execute();
     }
     /***********************************************************************************************
     		 settings
     		***********************************************************************************************/
     $settings = \DBUtil::checkIfExist('settings');
     if (!$settings) {
         \DBUtil::create_table('settings', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'value' => array('constraint' => 200, 'type' => 'varchar'), 'meta_update_user' => array('constraint' => 11, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
     }
     /***********************************************************************************************
     		 FOREIGN KEYS
     		***********************************************************************************************/
     /***********************************************************************************************
     		 sentry
     		***********************************************************************************************/
     $table = \DBUtil::checkIfExist('users');
     if (!$table) {
         \DBUtil::create_table('users', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'username' => array('constraint' => 50, 'type' => 'varchar'), 'email' => array('constraint' => 50, 'type' => 'varchar'), 'password' => array('constraint' => 81, 'type' => 'varchar'), 'password_reset_hash' => array('constraint' => 81, 'type' => 'varchar'), 'temp_password' => array('constraint' => 81, 'type' => 'varchar'), 'remember_me' => array('constraint' => 81, 'type' => 'varchar'), 'activation_hash' => array('constraint' => 81, 'type' => 'varchar'), 'last_login' => array('constraint' => 11, 'type' => 'int'), 'ip_address' => array('constraint' => 50, 'type' => 'varchar'), 'updated_at' => array('constraint' => 11, 'type' => 'int'), 'created_at' => array('constraint' => 11, 'type' => 'int'), 'status' => array('constraint' => 1, 'type' => 'tinyint'), 'activated' => array('contsraint' => 1, 'type' => 'tinyint')), array('id'));
     }
     $table = \DBUtil::checkIfExist('users_metadata');
     if (!$table) {
         \DBUtil::create_table('users_metadata', array('user_id' => array('constraint' => 11, 'type' => 'int'), 'first_name' => array('constraint' => 50, 'type' => 'varchar'), 'last_name' => array('constraint' => 50, 'type' => 'varchar')), array('user_id'));
     }
     $table = \DBUtil::checkIfExist('users_suspended');
     if (!$table) {
         \DBUtil::create_table('users_suspended', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'login_id' => array('constraint' => 50, 'type' => 'varchar'), 'attempts' => array('constraint' => 50, 'type' => 'int'), 'ip' => array('constraint' => 25, 'type' => 'varchar'), 'last_attempt_at' => array('constraint' => 11, 'type' => 'int'), 'suspended_at' => array('constraint' => 11, 'type' => 'int'), 'unsuspend_at' => array('constraint' => 11, 'type' => 'int')), array('id'));
     }
     $table = \DBUtil::checkIfExist('users_groups');
     if (!$table) {
         \DBUtil::create_table('users_groups', array('user_id' => array('constraint' => 11, 'type' => 'int'), 'group_id' => array('constraint' => 11, 'type' => 'int')));
     }
     /***********************************************************************************************
     		 version
     		***********************************************************************************************/
     $table = \DBUtil::checkIfExist('version');
     if ($table) {
         \DBUtil::drop_table('version');
         $table = false;
     }
     if (!$table) {
         \DBUtil::create_table('version', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'value' => array('constraint' => 200, 'type' => 'varchar'), 'meta_update_time' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'lastcheck' => array('constraint' => 11, 'type' => 'int', 'default' => '0'), 'mode' => array('constraint' => 22, 'type' => 'varchar'), 'master' => array('constraint' => 22, 'type' => 'varchar'), 'quiet' => array('constraint' => 2, 'type' => 'int', 'default' => '0')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
         $now = time();
         $master = '1.0';
         list($insert_id, $rows_affected) = \DB::insert('version')->columns(array('id', 'value', 'meta_update_time', 'lastcheck', 'mode', 'master', 'quiet'))->values(array('1', $master, $now, $now, '0', $master, 0))->execute();
     }
     /***********************************************************************************************
     		 simple log
     		***********************************************************************************************/
     $table = \DBUtil::checkIfExist('simple_log');
     if (!$table) {
         \DBUtil::create_table('simple_log', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'value' => array('type' => 'text')), array('id'), true, 'InnoDB', 'utf8_unicode_ci');
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:70,代码来源:001_installnucl.php


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