本文整理匯總了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']);
}
}
}
}
}
}