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


PHP NetworkPort::addToDB方法代码示例

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


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

示例1: Infocom

 function post_addItem()
 {
     global $DB;
     // Manage add from template
     if (isset($this->input["_oldID"])) {
         // ADD Infocoms
         $ic = new Infocom();
         if ($this->canUseInfocoms() && $ic->getFromDBforDevice($this->type, $this->input["_oldID"])) {
             $ic->fields["items_id"] = $this->fields['id'];
             unset($ic->fields["id"]);
             if (isset($ic->fields["immo_number"])) {
                 $ic->fields["immo_number"] = autoName($ic->fields["immo_number"], "immo_number", 1, 'Infocom', $this->input['entities_id']);
             }
             if (empty($ic->fields['use_date'])) {
                 unset($ic->fields['use_date']);
             }
             if (empty($ic->fields['buy_date'])) {
                 unset($ic->fields['buy_date']);
             }
             $ic->addToDB();
         }
         foreach (array('Document_Item' => 'documents_id', 'Contract_Item' => 'contracts_id') as $type => $fk) {
             $item = new $type();
             foreach ($item->find("items_id='" . $this->input["_oldID"] . "'\n                                 AND itemtype='" . $this->type . "'") as $tmpid => $data) {
                 $tmp = array();
                 $tmp['items_id'] = $this->input["_oldID"];
                 $tmp['itemtype'] = $type;
                 $tmp[$fk] = $data[$fk];
                 $item->add($tmp);
             }
         }
         if ($this->canUseNetworkPorts()) {
             // ADD Ports
             $query = "SELECT `id`\n                       FROM `glpi_networkports`\n                       WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                          AND `itemtype` = '" . get_called_class() . "';";
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 while ($data = $DB->fetch_array($result)) {
                     $np = new NetworkPort();
                     $npv = new NetworkPort_Vlan();
                     $np->getFromDB($data["id"]);
                     unset($np->fields["id"]);
                     unset($np->fields["ip"]);
                     unset($np->fields["mac"]);
                     unset($np->fields["netpoints_id"]);
                     $np->fields["items_id"] = $this->fields['id'];
                     $portid = $np->addToDB();
                     foreach ($DB->request('glpi_networkports_vlans', array('networkports_id' => $data["id"])) as $vlan) {
                         $npv->assignVlan($portid, $vlan['vlans_id']);
                     }
                 }
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:54,代码来源:object.class.php

示例2: Infocom

 function post_addItem()
 {
     global $DB, $CFG_GLPI;
     // Manage add from template
     if (isset($this->input["_oldID"])) {
         // ADD Infocoms
         $ic = new Infocom();
         $ic->cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
         // ADD Ports
         $query = "SELECT `id`\n                   FROM `glpi_networkports`\n                   WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                         AND `itemtype` = '" . $this->getType() . "'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             while ($data = $DB->fetch_array($result)) {
                 $np = new NetworkPort();
                 $npv = new NetworkPort_Vlan();
                 $np->getFromDB($data["id"]);
                 unset($np->fields["id"]);
                 unset($np->fields["ip"]);
                 unset($np->fields["mac"]);
                 unset($np->fields["netpoints_id"]);
                 $np->fields["items_id"] = $this->fields['id'];
                 $portid = $np->addToDB();
                 foreach ($DB->request('glpi_networkports_vlans', array('networkports_id' => $data["id"])) as $vlan) {
                     $npv->assignVlan($portid, $vlan['vlans_id']);
                 }
             }
         }
         // ADD Contract
         $query = "SELECT `contracts_id`\n                   FROM `glpi_contracts_items`\n                   WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                         AND `itemtype` = '" . $this->getType() . "'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             $contractitem = new Contract_Item();
             while ($data = $DB->fetch_array($result)) {
                 $contractitem->add(array('contracts_id' => $data["contracts_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
             }
         }
         // ADD Documents
         $query = "SELECT `documents_id`\n                   FROM `glpi_documents_items`\n                   WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                         AND `itemtype` = '" . $this->getType() . "'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             $docitem = new Document_Item();
             while ($data = $DB->fetch_array($result)) {
                 $docitem->add(array('documents_id' => $data["documents_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
             }
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:47,代码来源:phone.class.php


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