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


PHP Device::add方法代码示例

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


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

示例1: catch

        $selected_device = NULL;
    }
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Execute actions
 *
 *********************************************************************************/
if (!$fatal_error) {
    switch ($action) {
        case 'add':
            try {
                $new_device = Device::add($database, $current_user, $log, $new_name, $new_parent_id);
                $html->set_variable('refresh_navigation_frame', true, 'boolean');
                if (!$add_more) {
                    $selected_device = $new_device;
                    $selected_id = $selected_device->get_id();
                }
            } catch (Exception $e) {
                $messages[] = array('text' => 'Die neue Baugruppe konnte nicht angelegt werden!', 'strong' => true, 'color' => 'red');
                $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
            }
            break;
        case 'delete':
            try {
                if (!is_object($selected_device)) {
                    throw new Exception('Es ist keine Baugruppe markiert oder es trat ein Fehler auf!');
                }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:31,代码来源:edit_devices.php

示例2: Device

 public static function Device($type, $data)
 {
     require_once 'device.class.php';
     $class = new Device();
     $status = false;
     $class->setData($data);
     $class->filter = ManagementFunction::getPostVariable('filter');
     switch ($type) {
         case 'add':
             $status = $class->add();
             break;
         case 'update':
             $status = $class->update();
             break;
         case 'delete':
             $status = $class->delete();
             break;
         case 'getsingle':
             $status = $class->getsingle();
             break;
         case 'getpage':
             $status = $class->getpage();
             break;
         case 'search':
             $status = $class->search();
             break;
         default:
             break;
     }
     if ($status) {
         wp_send_json_success($status);
     } else {
         wp_send_json_error($class->error);
     }
 }
开发者ID:khiconit,项目名称:Device-manager,代码行数:35,代码来源:ManagementAdmin.class.php

示例3: copy

 /**
  * @brief Create a new Device as a copy from this one. All DeviceParts will be copied too.
  *
  * @param string $name                  The name of the new device
  * @param integer $parent_id            The ID of the new device's parent device
  * @param boolean   $with_subdevices    If true, all subdevices will be copied too
  *
  * @throws Exception if there was an error
  */
 public function copy($name, $parent_id, $with_subdevices = false)
 {
     try {
         if ($with_subdevices && $parent_id > 0) {
             // check if $parent_id is NOT a child of this device
             $parent_device = new Device($this->database, $this->current_user, $this->log, $parent_id);
             if ($parent_device->get_id() == $this->get_id() || $parent_device->is_child_of($this)) {
                 throw new Exception('Eine Baugruppe kann nicht in sich selber kopiert werden!');
             }
         }
         $transaction_id = $this->database->begin_transaction();
         // start transaction
         $new_device = Device::add($this->database, $this->current_user, $this->log, $name, $parent_id);
         $device_parts = $this->get_parts();
         foreach ($device_parts as $part) {
             $new_part = DevicePart::add($this->database, $this->current_user, $this->log, $new_device->get_id(), $part->get_part()->get_id(), $part->get_mount_quantity(), $part->get_mount_names());
         }
         if ($with_subdevices) {
             $subdevices = $this->get_subelements(false);
             foreach ($subdevices as $device) {
                 $device->copy($device->get_name(), $new_device->get_id(), true);
             }
         }
         $this->database->commit($transaction_id);
         // commit transaction
     } catch (Exception $e) {
         $this->database->rollback();
         // rollback transaction
         throw new Exception("Die Baugruppe \"" . $this->get_name() . "\"konnte nicht kopiert werden!\nGrund: " . $e->getMessage());
     }
 }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:40,代码来源:class.Device.php


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