Load() public static method

Load DBInstance by database id
public static Load ( $farmid, $roleid, $cloudLocation ) : DBFarmRole
return DBFarmRole
コード例 #1
0
ファイル: Roles.php プロジェクト: recipe/scalr
 public function xGetRoleParamsAction()
 {
     $this->request->defineParams(array('roleId' => array('type' => 'int'), 'farmId' => array('type' => 'int'), 'cloudLocation'));
     try {
         $dbRole = DBRole::loadById($this->getParam('roleId'));
         if ($dbRole->envId != 0) {
             $this->user->getPermissions()->validate($dbRole);
         }
     } catch (Exception $e) {
         $this->response->data(array('params' => array()));
         return;
     }
     $params = $this->db->GetAll("SELECT * FROM role_parameters WHERE role_id=? AND hash NOT IN('apache_http_vhost_template','apache_https_vhost_template')", array($dbRole->id));
     foreach ($params as $key => $param) {
         $value = false;
         try {
             if ($this->getParam('farmId')) {
                 $dbFarmRole = DBFarmRole::Load($this->getParam('farmId'), $this->getParam('roleId'), $this->getParam('cloudLocation'));
                 $value = $this->db->GetOne("SELECT value FROM farm_role_options WHERE farm_roleid=? AND hash=? LIMIT 1", array($dbFarmRole->ID, $param['hash']));
             }
         } catch (Exception $e) {
         }
         // Get field value
         if ($value === false || $value === null) {
             $value = $param['defval'];
         }
         $params[$key]['value'] = str_replace("\r", "", $value);
     }
     $this->response->data(array('params' => $params));
 }