/** * Returns the current version of the database. * * Null when the version is unknown * * @return null|string */ public function getDatabaseVersion() { try { return $this->client->getSetting(Settings::DATABASE_VERSION); } catch (\PDOException $e) { return null; } }
/** * @param Client $client * * @return $this */ public function sortAndLimit($client) { // Make sure we have a valid column to sort by $sortColumn = $client->getSetting(Settings::SORT); $columnMap = $this->toAssoc(); if (!isset($columnMap[$sortColumn])) { $sortColumn = 'hit_count'; } // Large hit counts and latest time stamps come first if ($sortColumn === 'hit_count' || substr($sortColumn, 0, 3) === 'ts_') { $this->orderDesc($sortColumn); } else { $this->orderAsc($sortColumn); } // Only limit when set $maxRows = $client->getSetting(Settings::LIMIT); if ($maxRows > 0) { $this->limit($maxRows); } return $this; }