本文整理汇总了PHP中Infocom::addToDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Infocom::addToDB方法的具体用法?PHP Infocom::addToDB怎么用?PHP Infocom::addToDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Infocom
的用法示例。
在下文中一共展示了Infocom::addToDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
}
}
}
}
}
}