Back to ListModel class

Method _getListQuery

protected \Joomla\Database\DatabaseQuery
_getListQuery
()
Method to cache the last query constructed.
Returns
  • \Joomla\Database\DatabaseQuery A DatabaseQuery object
Since
  • 1.6
Class: ListModel
Project: Joomla

Method _getListQuery - Source code

/**
 * Method to cache the last query constructed.
 *
 * This method ensures that the query is constructed only once for a given state of the model.
 *
 * @return  DatabaseQuery  A DatabaseQuery object
 *
 * @since   1.6
 */
protected function _getListQuery()
{
    // Compute the current store id.
    $currentStoreId = $this->getStoreId();
    // If the last store id is different from the current, refresh the query.
    if ($this->lastQueryStoreId !== $currentStoreId || empty($this->query)) {
        $this->lastQueryStoreId = $currentStoreId;
        $this->query = $this->getListQuery();
    }
    return $this->query;
}