Returns fetched data.
@param bool $applyPaging
@param bool $useCache
@param bool $fetch
@throws Exception
@return array|DataSources\IDataSource|\Nette\Database\Table\Selection
516638
public function getData($applyPaging = TRUE, $useCache = TRUE, $fetch = TRUE)
    {
        if ($this->getModel() === NULL) {
            throw new Exception('Model cannot be empty, please use method $grid->setModel().');
        }

        $data = $this->data;
        if ($data === NULL || $useCache === FALSE) {
            $this->applyFiltering();
            $this->applySorting();

            if ($applyPaging) {
                $this->applyPaging();
            }

            if ($fetch === FALSE) {
                return $this->getModel();
            }

            $data = $this->getModel()->getData();

            if ($useCache === TRUE) {
                $this->data = $data;
            }

            if ($applyPaging && !empty($data) && !in_array($this->page, range(1, $this->getPaginator()->pageCount))) {
                $this->__triggerUserNotice("Page is out of range.");
                $this->page = 1;
            }

            if (!empty($this->onFetchData)) {
                $this->onFetchData($this);
            }
        }

        return $data;
    }
400794
public static function query(array $params = null, $useGet = false)
    {
        if ($useGet)
        {
            if (null === $params)
            {
                $params = $_GET;
            }
            else
            {
                $params = Arr::merge($_GET, $params);
            }
        }

        if (empty($params))
        {
            return '';
        }

        $query = http_build_query($params, '', '&');
        return ($query === '') ? '' : ('?' . $query);
    }
523011
public function dbFetchPairs($select_query, $parameters = array()) {

        $bool_and_statement = static::_execute($select_query, $parameters, true, $this->_connection_name);
        
        $statement = array_pop($bool_and_statement);
        
        $data = array();
        
        while ($row = $statement->fetch(\PDO::FETCH_NUM)) {
            
            $data[$row[0]] = $row[1];
        }
            
        return $data;
    }
1246495
public function fetch($filename, $cacheId = null, $compileId = null, $display = false)
    {
        $this->setCacheDir($this->cache_dir);
        $this->setCompileDir($this->compile_dir);

        if ($this->security) {
            $policy = new SecurityPolicy();
            $policy->addPhpFunction(array_merge($this->security_settings['IF_FUNCS'], $this->security_settings['MODIFIER_FUNCS']));

            $phpTags = $this->security_settings['PHP_HANDLING'] ? SMARTY_PHP_ALLOW : $this->php_handling;
            if ($this->security_settings['PHP_TAGS']) {
                $phpTags = SMARTY_PHP_ALLOW;
            }
            switch ($phpTags) {
            case SMARTY_PHP_ALLOW:
            case SMARTY_PHP_PASSTHRU:
                $phpTags = SecurityPolicy::PHP_ALLOW;
                break;
            case SMARTY_PHP_QUOTE:
                $phpTags = SecurityPolicy::PHP_ENCODE;
                break;
            case SMARTY_PHP_REMOVE:
            default:
                $phpTags = SecurityPolicy::PHP_REMOVE;
                break;
            }
            $policy->setPhpHandling($phpTags);

            $policy->setConstantHandling($this->security_settings['ALLOW_CONSTANTS']);

            if ($this->security_settings['INCLUDE_ANY']) {
                $policy->allowDirectory(preg_replace('{^((?:[a-z]:)?[\\\\/]).*}i', '$1', __FILE__));
            } else {
                $policy->allowDirectory($this->secure_dir);
            }

            $this->setSecurityPolicy($policy);
        }

        if (!empty($this->plugins_dir)) {
            foreach ($this->plugins_dir as $dir) {
                $this->getLoader()->addDirectory(rtrim($dir, '\\/'));
            }
        }

        $tpl = $this->makeTemplate($filename, $cacheId, $compileId);
        if ($this->force_compile) {
            $tpl->forceCompilation();
        }

        if ($this->caching > 0) {
            $this->cacheTime = $this->cache_lifetime;
        } else {
            $this->cacheTime = 0;
        }

        if ($this->compiler_class !== null) {
            if ($this->compiler_file !== null && !class_exists($this->compiler_class)) {
                include $this->compiler_file;
            }
            $this->compiler = new $this->compiler_class();
        } else {
            $this->compiler->addPreProcessor('PluginSmartyCompatible', true);
            $this->compiler->setLooseOpeningHandling(true);
        }

        $this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter);

        return $this->get($tpl, $this->dataProvider, $this->compiler, $display === true);
    }
468944
public function fetch(FilterRequestEvent $event)
    {
        if ($this->cache === null) {
            return null;
        }
        $request = $event->getRequest();
        if (!$this->cache->has($request->getUrl())) {
            return null;
        }
        /** @var $response CachedResponse */
        $response = $this->cache->get($request->getUrl());
        if (empty($response)) {
            return null;
        }
        $this->log->write(Log::INFO, 'HTTPCache', 'Cache hit for path: %s', $request->getUrl());
        $this->from_cache = true;

        $main = $this->container->get('Miny\\HTTP\\Response');
        foreach ($response->getParts() as $part) {
            if ($part instanceof CachedResponse) {
                $main->addResponse(
                    $this->container->get('Miny\\Application\\Dispatcher')->dispatch(
                        $part->getRequest()
                    )
                );
            } else {
                $main->addContent($part);
            }
        }

        return $response;
    }
209726
public function fetch()
        {
            try {
                if ($this->values = $this->statement->fetch(\PDO::FETCH_ASSOC)) {
                    return $this->values;
                } else {
                    return false;
                }
            } catch (\PDOException $e) {
                throw new Exception('An error occured while trying to fetch the result: "' . $e->getMessage() . '"');
            }
        }
177996
protected function _get()
	{
		// get the apc key for the cache identifier
		$key = $this->_get_key();

		// fetch the cached data from the apc store
		$payload = apc_fetch($key);

		try
		{
			$this->unprep_contents($payload);
		}
		catch (\UnexpectedValueException $e)
		{
			return false;
		}

		return true;
	}
1120213
public function fetchResults($query, $page = 1, $maxPerPage = 10, $filter = false, $paginate = false)
    {
        if ($paginate) {
            if (!$this->pager) {
                throw new \Exception('Please inject a pager on ResultBuilder');
            }

            $results = $this->pager->paginate($query, $page, $maxPerPage);
        } else {
            $results = $this->queryExecutor->fetch($query, $page, $maxPerPage);
        }

        if ($filter) {
            return $this->filterManager->filter($results);
        }

        return $results;
    }
1234392
public function getSite($domain, $useCache = true)
    {
        $site = null;

        if ($useCache) {
            $site = $this->getCache($domain);
        }

        if (!empty($site)) {
            return $site;
        }

        $site = $this->siteRepo->getSiteByDomain($domain);

        if (empty($site)) {
            $site = new Site(
                Tracking::UNKNOWN_USER_ID,
                'Fake site due to site domain not found ' . get_class($this)
            );
        }

        return $site;
    }
827371
function get($resource, $query = array(), $headers = array()) {
        $url = $this->build_url($resource, $query);
        $key = $this->buildCacheKey('get', $resource, $url, $headers, $query);
        if (($this->cacher) && ($this->cacher->has($key))) return $this->cacher->get($key);
        $result = $this->client->get($url, [
            'headers' => array_merge([
                'Authorization' => $this->getBearer()
            ], $headers)
        ])->json();
        if ($this->cacher) $this->cacher->put($key, $result);
        return $result;
    }
170800
function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
	{
		static $_cache_info = array();

		$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
		? $this->error_reporting : error_reporting() & ~E_NOTICE);

		if (!$this->debugging && $this->debugging_ctrl == 'URL') {
			$_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
			if (@strstr($_query_string, $this->_smarty_debug_id)) {
				if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
					// enable debugging for this browser session
					@setcookie('SMARTY_DEBUG', true);
					$this->debugging = true;
				} elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
					// disable debugging for this browser session
					@setcookie('SMARTY_DEBUG', false);
					$this->debugging = false;
				} else {
					// enable debugging for this page
					$this->debugging = true;
				}
			} else {
				$this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
			}
		}

		if ($this->debugging) {
			// capture time for debugging info
			$_params = array();
			require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
			$_debug_start_time = smarty_core_get_microtime($_params, $this);
			$this->_smarty_debug_info[] = array('type'      => 'template',
                                                'filename'  => $resource_name,
                                                'depth'     => 0);
			$_included_tpls_idx = count($this->_smarty_debug_info) - 1;
		}

		if (!isset($compile_id)) {
			$compile_id = $this->compile_id;
		}

		$this->_compile_id = $compile_id;
		$this->_inclusion_depth = 0;

		if ($this->caching) {
			// save old cache_info, initialize cache_info
			array_push($_cache_info, $this->_cache_info);
			$this->_cache_info = array();
			$_params = array(
                'tpl_file' => $resource_name,
                'cache_id' => $cache_id,
                'compile_id' => $compile_id,
                'results' => null
			);
			require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
			if (smarty_core_read_cache_file($_params, $this)) {
				$_smarty_results = $_params['results'];
				if (!empty($this->_cache_info['insert_tags'])) {
					$_params = array('plugins' => $this->_cache_info['insert_tags']);
					require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
					smarty_core_load_plugins($_params, $this);
					$_params = array('results' => $_smarty_results);
					require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
					$_smarty_results = smarty_core_process_cached_inserts($_params, $this);
				}
				if (!empty($this->_cache_info['cache_serials'])) {
					$_params = array('results' => $_smarty_results);
					require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
					$_smarty_results = smarty_core_process_compiled_include($_params, $this);
				}


				if ($display) {
					if ($this->debugging)
					{
						// capture time for debugging info
						$_params = array();
						require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
						$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
						require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
						$_smarty_results .= smarty_core_display_debug_console($_params, $this);
					}
					if ($this->cache_modified_check) {
						$_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
						$_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
						$_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
						if (@count($this->_cache_info['insert_tags']) == 0
						&& !$this->_cache_serials
						&& $_gmt_mtime == $_last_modified_date) {
							if (php_sapi_name()=='cgi')
							header('Status: 304 Not Modified');
							else
							header('HTTP/1.1 304 Not Modified');

						} else {
							header('Last-Modified: '.$_gmt_mtime);
							echo $_smarty_results;
						}
					} else {
						echo $_smarty_results;
					}
					error_reporting($_smarty_old_error_level);
					// restore initial cache_info
					$this->_cache_info = array_pop($_cache_info);
					return true;
				} else {
					error_reporting($_smarty_old_error_level);
					// restore initial cache_info
					$this->_cache_info = array_pop($_cache_info);
					return $_smarty_results;
				}
			} else {
				$this->_cache_info['template'][$resource_name] = true;
				if ($this->cache_modified_check && $display) {
					header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
				}
			}
		}

		// load filters that are marked as autoload
		if (count($this->autoload_filters)) {
			foreach ($this->autoload_filters as $_filter_type => $_filters) {
				foreach ($_filters as $_filter) {
					$this->load_filter($_filter_type, $_filter);
				}
			}
		}

		$_smarty_compile_path = $this->_get_compile_path($resource_name);

		// if we just need to display the results, don't perform output
		// buffering - for speed
		$_cache_including = $this->_cache_including;
		$this->_cache_including = false;
		if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
			if ($this->_is_compiled($resource_name, $_smarty_compile_path)
			|| $this->_compile_resource($resource_name, $_smarty_compile_path))
			{
				include($_smarty_compile_path);
			}
		} else {
			ob_start();
			if ($this->_is_compiled($resource_name, $_smarty_compile_path)
			|| $this->_compile_resource($resource_name, $_smarty_compile_path))
			{
				include($_smarty_compile_path);
			}
			$_smarty_results = ob_get_contents();
			ob_end_clean();

			foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
				$_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
			}
		}

		if ($this->caching) {
			$_params = array('tpl_file' => $resource_name,
                        'cache_id' => $cache_id,
                        'compile_id' => $compile_id,
                        'results' => $_smarty_results);
			require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
			smarty_core_write_cache_file($_params, $this);
			require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
			$_smarty_results = smarty_core_process_cached_inserts($_params, $this);

			if ($this->_cache_serials) {
				// strip nocache-tags from output
				$_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
				,''
				,$_smarty_results);
			}
			// restore initial cache_info
			$this->_cache_info = array_pop($_cache_info);
		}
		$this->_cache_including = $_cache_including;

		if ($display) {
			if (isset($_smarty_results)) { echo $_smarty_results; }
			if ($this->debugging) {
				// capture time for debugging info
				$_params = array();
				require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
				$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
				require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
				echo smarty_core_display_debug_console($_params, $this);
			}
			error_reporting($_smarty_old_error_level);
			return;
		} else {
			error_reporting($_smarty_old_error_level);
			if (isset($_smarty_results)) { return $_smarty_results; }
		}
	}
1107507
protected function getCache($sKey, $bReturnValue = true)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        $sCacheKey = $this->getCachePrefix() . $sKey;
        foreach ($this->aCache as $iIndex => $oCacheItem) {
            if (in_array($sCacheKey, $oCacheItem->key)) {
                return $bReturnValue ? $oCacheItem->value : $iIndex;
            }
        }

        return null;
    }
308903
static function fetchByID( $id, $cacheInfoList = false )
    {
        if ( !$cacheInfoList )
            $cacheInfoList = eZCache::fetchList();

        foreach ( $cacheInfoList as $cacheInfo )
        {
            if ( $cacheInfo['id'] == $id )
                return $cacheInfo;
        }
        return false;
    }
608747
public function fetch() {
		if ($this->selection) {
			$fetch = $this->selection->fetch();
			if ($fetch) {
				return $this->createEntity($fetch);
			} else {
				return array();
			}
		} else {
			return array();
		}
	}
839042
private function downloadMe($cache = true)
    {
        if (empty($this->httpClient)) {
            throw new ClientError('Missing HTTP client to use for this operation.');
        }

        if ($cache) {
            if (empty($this->store)) {
                throw new ClientError('Missing store instance to use for this operation.');
            }

            if ($this->cached) {
                return null;
            }

            $this->cached = true;
        }

        try {
            $response = $this->httpClient->get($this->url);
            if ($response->getStatusCode() != 200) {
                throw new \Exception('Unable to download.');
            }
            if (!$cache) {
                return $response->getBody();
            }

            $this->store->set($this->getKey($this->url), $response->getBody());
        } catch (\Exception $e) {
            $this->cached = false;
            throw $e;
        }
        return null;
    }
885153
protected function fetch($key)
    {
        $success = false;

        if (function_exists('apcu_fetch')) {
            $data = apcu_fetch($key, $success);
        } else {
            $data = apc_fetch($key, $success);
        }

        $this->debugSection('Fetching a stored variable', $success ? 'OK' : 'FAILED');

        return $data;
    }
662247
public function get_tables($usecache=true) {
        if ($usecache and $this->tables !== null) {
            return $this->tables;
        }
        $this->tables = array();
        $prefix = str_replace('_', '|_', $this->prefix);
        $sql = "SELECT c.relname
                  FROM pg_catalog.pg_class c
                  JOIN pg_catalog.pg_namespace as ns ON ns.oid = c.relnamespace
                 WHERE c.relname LIKE '$prefix%' ESCAPE '|'
                       AND c.relkind = 'r'
                       AND (ns.nspname = current_schema() OR ns.oid = pg_my_temp_schema())";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = pg_query($this->pgsql, $sql);
        $this->query_end($result);

        if ($result) {
            while ($row = pg_fetch_row($result)) {
                $tablename = reset($row);
                if ($this->prefix !== false && $this->prefix !== '') {
                    if (strpos($tablename, $this->prefix) !== 0) {
                        continue;
                    }
                    $tablename = substr($tablename, strlen($this->prefix));
                }
                $this->tables[$tablename] = $tablename;
            }
            pg_free_result($result);
        }
        return $this->tables;
    }