Exemplo n.º 1
0
 /**
     @param $comparator '<' || '>'
     @return $f OmekaFile || null
     Helper function for get{Next,Prev}().
 */
 private function getNeighbour($comparator)
 {
     //Sanitizing $comparator:
     if ($comparator !== '>' && $comparator !== '<') {
         return null;
     }
     $order = $comparator === '>' ? 'ASC' : 'DESC';
     //Current $urn:
     $urn = $this->getUrn();
     //Discovering $prefix for files that belong to the same item:
     $parts = explode('_', $urn);
     array_pop($parts);
     //Remove last part of urn
     $prefix = implode('_', $parts) . '%';
     //Query to use:
     $q = "SELECT urn, omekaUrl, scanDataJSON FROM scans " . "WHERE urn LIKE ? AND urn {$comparator} ? " . "ORDER BY (urn) {$order} LIMIT 1";
     $stmt = Config::getDB()->prepare($q);
     $stmt->bind_param('ss', $prefix, $urn);
     $f = OmekaFile::fileFromDbData($stmt);
     if (count($f) === 1) {
         return current($f);
     }
     return null;
 }