當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Device::fromDatabaseById方法代碼示例

本文整理匯總了PHP中Device::fromDatabaseById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Device::fromDatabaseById方法的具體用法?PHP Device::fromDatabaseById怎麽用?PHP Device::fromDatabaseById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Device的用法示例。


在下文中一共展示了Device::fromDatabaseById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: removeDevice

 public function removeDevice()
 {
     $dev_id = $_GET['dev_id'];
     $device = Device::fromDatabaseById($dev_id);
     if ($device) {
         if ($device->delete()) {
             return 'true';
         }
     }
     return 'false';
 }
開發者ID:adntec,項目名稱:queueManage,代碼行數:11,代碼來源:RemoveRecord.php

示例2: execute

 public function execute()
 {
     global $gvPath;
     // Trim data
     $this->dev_ip_address = trim($this->dev_ip_address);
     $this->dev_desk_number = trim($this->dev_desk_number);
     // Data validation
     if ($this->dev_ip_address === '' || $this->dev_desk_number === '') {
         $this->message = "Errore: tutti i campi sono obbligatori.";
         return true;
     }
     // dev_desk_number should contain... numbers
     if (preg_match('/^(0|[1-9][0-9]*)$/', $this->dev_desk_number) !== 1) {
         $this->message = "Errore: il numero dello sportello non è valido.";
         return true;
     }
     // Check ip_address
     if (!filter_var($this->dev_ip_address, FILTER_VALIDATE_IP)) {
         $this->message = "Errore: l'indirizzo IP non è valido.";
         return true;
     }
     // Check if desk number really exists
     if ((int) $this->dev_desk_number !== 0) {
         $desk = Desk::fromDatabaseByNumber($this->dev_desk_number);
         if (!$desk) {
             $this->message = "Errore: lo sportello specificato non esiste.";
             return true;
         }
         unset($desk);
     }
     // Check tdCode exists and active
     if ($this->dev_td_code) {
         $td = TopicalDomain::fromDatabaseByCode($this->dev_td_code);
         if (!$td || !$td->getActive()) {
             $this->message = "Errore: l'area tematica selezionata non è disponibile.";
             return true;
         }
     }
     // Check ip is not taken
     $device = Device::fromDatabaseByIpAddress($this->dev_ip_address);
     $desk = Desk::fromDatabaseByIpAddress($this->dev_ip_address);
     if ($desk || $device && ($this->dev_id === 0 || $this->dev_id !== (int) $device->getId())) {
         $this->message = "Errore: l'indirizzo IP è gia stato assegnato.";
         return true;
     }
     unset($device);
     if ($this->dev_id === 0) {
         $device = Device::newRecord();
     } else {
         $device = Device::fromDatabaseById($this->dev_id);
     }
     $device->setIpAddress($this->dev_ip_address);
     $device->setDeskNumber($this->dev_desk_number);
     $device->setTdCode($this->dev_td_code);
     if ($device->save()) {
         gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok');
         $redirect = new RedirectOutput("{$gvPath}/application/adminDeviceList");
         return $redirect;
     } else {
         $this->message = "Impossibile salvare le modifiche. Ritentare in seguito.";
         return true;
     }
 }
開發者ID:adntec,項目名稱:queueManage,代碼行數:63,代碼來源:AdminDeviceEdit.php


注:本文中的Device::fromDatabaseById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。