本文整理汇总了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;
}
}
示例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'])));
}