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


PHP Manufacturer::getFromDB方法代码示例

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


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

示例1: foreach

 echo "Processing : $type\n";
 foreach (file($URL) as $line) {
    if ($line[0] == '#') {
       continue;
    }
    $line = rtrim($line);
    if (empty($line)) {
       continue;
    }
    if ($line[0] != '\t') {
       $id   = strtolower(substr($line, 0, 4));
       $name = addslashes(trim(substr($line, 4)));
       if ($registeredid->getFromDBByQuery("WHERE `itemtype` = 'Manufacturer'
                                                  AND `name` = '$id'
                                                  AND `device_type` = '$type'")) {
          $manufacturer->getFromDB($registeredid->fields['items_id']);
       } else {
          if (!$manufacturer->getFromDBByQuery("WHERE `name` = '$name'")) {
             $input = array('name' => $name);
             $manufacturer->add($input);
          }
          $input = array('itemtype'    => $manufacturer->getType(),
                         'items_id'    => $manufacturer->getID(),
                         'device_type' => $type,
                         'name'        => $id);
          $registeredid->add($input);
       }
       continue;
    }
    // if (($line[0] == "\t") && ($line[1] != '\t'))  {
    //    $line = trim($line);
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:31,代码来源:update_registered_ids.php

示例2: testSoftwareImport

 /**
  * test for addOrRestoreFromTrash
  */
 public function testSoftwareImport()
 {
     $ent0 = $this->sharedFixture['entity'][0];
     $ent1 = $this->sharedFixture['entity'][1];
     $ent2 = $this->sharedFixture['entity'][2];
     $soft = new Software();
     $manu = new Manufacturer();
     // Import Software
     $id[0] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
     $this->assertGreaterThan(0, $id[0], "Fail: can't create software 1");
     // Check name
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $this->assertEquals('GLPI', $soft->getField('name'), "Fail: name not set");
     // Check manufacturer
     $manid = $soft->getField('manufacturers_id');
     $this->assertGreaterThan(0, $manid, "Fail: manufacturer not set");
     $this->assertTrue($manu->getFromDB($manid), "Fail: can't manufacturer");
     $this->assertEquals('Indepnet', $manu->getField('name'));
     // Import again => same result
     $id[1] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
     $this->assertGreaterThan(0, $id[1], "Fail: can't create software 2");
     $this->assertEquals($id[0], $id[1], "Fail: previous not found");
     // Import in another entity
     $id[2] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent1);
     $this->assertGreaterThan(0, $id[2], "Fail: can't create software 3");
     $this->assertNotEquals($id[0], $id[2], "Fail: previous used (from another entity)");
     // Delete
     $this->assertTrue($soft->delete(array('id' => $id[2])), "Fail: can't delete software 3)");
     $this->assertTrue($soft->getFromDB($id[2]), "Fail: can't read new soft");
     $this->assertEquals(1, $soft->getField('is_deleted'), "Fail: soft not deleted");
     // Import again => restore
     $id[3] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent1);
     $this->assertEquals($id[2], $id[3], "Fail: previous not used");
     $this->assertTrue($soft->getFromDB($id[2]), "Fail: can't read new soft");
     $this->assertEquals(0, $soft->getField('is_deleted'), "Fail: soft not restored");
     // Import again => with recursive
     $this->assertTrue($soft->update(array('id' => $id[0], 'is_recursive' => 1)), "Fail: can't update software 1)");
     $id[4] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent2);
     $this->assertEquals($id[0], $id[4], "Fail: previous not used");
     // Clean
     $this->assertTrue($soft->delete(array('id' => $id[0]), true), "Fail: can't delete software 1)");
     $this->assertTrue($soft->delete(array('id' => $id[2]), true), "Fail: can't delete software 1)");
 }
开发者ID:btry,项目名称:glpi,代码行数:46,代码来源:Import.php


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