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


PHP DBFarm::LoadById方法代碼示例

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


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

示例1: getFarmWidgetRoles

 public function getFarmWidgetRoles($farmId, $options)
 {
     $dbFarm = DBFarm::LoadById($farmId);
     $this->user->getPermissions()->validate($dbFarm);
     $dataFarmRoles = array();
     $behaviors = array();
     foreach ($options as $key => $value) {
         $matches = explode('_', $value);
         if ($matches[0] == 'behavior' && $matches[1]) {
             $behaviors[] = $matches[1];
         }
     }
     foreach ($this->db->GetAll("SELECT id, platform, role_id, alias AS name FROM farm_roles WHERE farmid = ?", array($dbFarm->ID)) as $farmRole) {
         try {
             $dbRole = DBRole::loadById($farmRole['role_id']);
             if (!empty($behaviors)) {
                 $bFilter = false;
                 foreach ($behaviors as $behavior) {
                     if ($dbRole->hasBehavior($behavior)) {
                         $bFilter = true;
                         break;
                     }
                 }
                 if (!$bFilter) {
                     continue;
                 }
             }
         } catch (Exception $e) {
             $farmRole['name'] = '*removed*';
         }
         array_push($dataFarmRoles, $farmRole);
     }
     if (count($dataFarmRoles) && in_array('addAll', $options)) {
         array_unshift($dataFarmRoles, array('id' => '0', 'name' => 'On all roles'));
     }
     if (in_array('addEmpty', $options)) {
         array_unshift($dataFarmRoles, array('id' => '', 'name' => ''));
     }
     if (!empty($dataFarmRoles)) {
         return $dataFarmRoles;
     } else {
         return null;
     }
 }
開發者ID:rickb838,項目名稱:scalr,代碼行數:44,代碼來源:Farms.php

示例2: executeAction

 public function executeAction()
 {
     $farmId = $this->getParam('farmId');
     $farmRoleId = $this->getParam('farmRoleId');
     $serverId = $this->getParam('serverId');
     $scriptId = $this->getParam('scriptId');
     $eventName = $this->getParam('eventName');
     $farms = array();
     $farmRoles = array();
     $servers = array();
     $scripts = $this->getList();
     sort($scripts);
     if ($eventName) {
         $scriptInfo = $this->db->GetRow("SELECT * FROM farm_role_scripts WHERE event_name=?", array($eventName));
         if (!$scriptInfo) {
             throw new Exception("Scalr unable to find script execution options for used link");
         }
         $farmId = $scriptInfo['farmid'];
         $farmRoleId = $scriptInfo['farm_roleid'];
         $scriptId = $scriptInfo['scriptid'];
     }
     if ($serverId) {
         $dbServer = DBServer::LoadByID($serverId);
         $farmRoleId = $dbServer->farmRoleId;
     }
     if ($farmRoleId) {
         $dbFarmRole = DBFarmRole::LoadByID($farmRoleId);
         $farmId = $dbFarmRole->FarmID;
         foreach ($dbFarmRole->GetServersByFilter(array('status' => SERVER_STATUS::RUNNING)) as $key => $value) {
             $servers[$value->serverId] = $value->remoteIp;
         }
         if (count($servers)) {
             $servers[0] = _('On all servers');
             if (!$serverId) {
                 $serverId = 0;
             }
         }
     }
     if ($farmId) {
         $dbFarm = DBFarm::LoadById($farmId);
         $this->user->getPermissions()->validate($dbFarm);
         $this->request->setParams(array('farmId' => $farmId));
         $farmRoles = self::loadController('Roles', 'Scalr_UI_Controller_Farms')->getList();
         if (count($farmRoles)) {
             $farmRoles[0] = array('id' => 0, 'name' => 'On all roles');
         }
     }
     $farms = self::loadController('Farms')->getList();
     $this->response->page('ui/scripts/execute.js', array('farms' => $farms, 'farmRoles' => $farmRoles, 'servers' => $servers, 'scripts' => $scripts, 'farmId' => $farmId, 'farmRoleId' => $farmRoleId, 'serverId' => $serverId, 'scriptId' => $scriptId, 'scriptIsSync' => $scriptInfo['issync'], 'scriptTimeout' => $scriptInfo['timeout'], 'scriptVersion' => $scriptInfo['version'], 'scriptOptions' => @unserialize($scriptInfo['params'])));
 }
開發者ID:rakesh-mohanta,項目名稱:scalr,代碼行數:50,代碼來源:Scripts.php


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