Nette\Database\Table\SqlBuilder::getSelectQueryHash PHP Méthode

getSelectQueryHash() public méthode

Returns select query hash for caching.
public getSelectQueryHash ( $columns = NULL ) : string
Résultat string
    public function getSelectQueryHash($columns = NULL)
    {
        $parts = ['delimitedTable' => $this->delimitedTable, 'queryCondition' => $this->buildConditions(), 'queryEnd' => $this->buildQueryEnd(), $this->aliases, $this->limit, $this->offset];
        if ($this->select) {
            $parts[] = $this->select;
        } elseif ($columns) {
            $parts[] = [$this->delimitedTable, $columns];
        } elseif ($this->group && !$this->driver->isSupported(ISupplementalDriver::SUPPORT_SELECT_UNGROUPED_COLUMNS)) {
            $parts[] = [$this->group];
        } else {
            $parts[] = "{$this->delimitedTable}.*";
        }
        return $this->getConditionHash(json_encode($parts), [$this->parameters['select'], $this->parameters['joinCondition'], $this->parameters['where'], $this->parameters['group'], $this->parameters['having'], $this->parameters['order']]);
    }

Usage Example

Exemple #1
0
 /**
  * Returns object specific cache key dependent on query parameters
  * Used e.g. for reference memory caching
  * @return string
  */
 protected function getSpecificCacheKey()
 {
     if ($this->specificCacheKey) {
         return $this->specificCacheKey;
     }
     return $this->specificCacheKey = $this->sqlBuilder->getSelectQueryHash($this->getPreviousAccessedColumns());
 }