Scalr\Farm\Role\FarmRoleStorageConfig::loadById PHP Метод

loadById() публичный Метод

public loadById ( $id )
    public function loadById($id)
    {
        $data = $this->db->GetRow('SELECT * FROM farm_role_storage_config WHERE id = ? AND farm_role_id = ? LIMIT 1', array($id, $this->farmRole->ID));
        if (empty($data)) {
            return false;
        }
        $this->id = $data['id'];
        $this->type = $data['type'];
        $this->index = $data['index'];
        $this->fs = $data['fs'];
        $this->reUse = $data['re_use'];
        $this->mount = $data['mount'];
        $this->mountPoint = $data['mountpoint'];
        $this->label = $data['label'];
        $this->mountOptions = $data['mount_options'];
        $this->rebuild = $data['rebuild'];
        $this->status = $data['status'];
        $this->settings = array();
        foreach ($this->db->GetAll('SELECT name, value FROM farm_role_storage_settings WHERE storage_config_id = ?', array($this->id)) as $value) {
            $this->settings[$value['name']] = $value['value'];
        }
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * @param \DBFarmRole $farmRole
  * @return FarmRoleStorageConfig[]
  */
 public static function getByFarmRole(\DBFarmRole $farmRole)
 {
     $db = \Scalr::getDb();
     $configs = array();
     $ids = $db->GetCol('SELECT id FROM farm_role_storage_config WHERE farm_role_id = ?', array($farmRole->ID));
     foreach ($ids as $id) {
         $config = new FarmRoleStorageConfig($farmRole);
         if ($config->loadById($id)) {
             $configs[] = $config;
         }
     }
     return $configs;
 }