/**
  * Search for listings, sort and filter
  * pass in an array of options from the following:
  * sort, only, floor, ceiling, seller, buyer, bidder, item_id
  * @see https://intranet.gaiaonline.com/wiki/devs/souk#search_for_listings
  * @return array
  */
 public function search($options)
 {
     // standardize the search options. makes it easer to manipulate.
     $options = Souk\Util::searchOptions($options);
     return $this->storage()->search($options);
 }
 public function close($listing)
 {
     // grab the shard and row id.
     list($shard, $row_id) = Souk\Util::parseId($listing->id);
     // update the listing.
     $table = $this->table($shard);
     if (\Gaia\Souk\Storage::isAutoSchemaEnabled()) {
         $this->create($table);
     }
     if (!Transaction::atStart()) {
         Transaction::add($this->db);
     }
     $sql = "UPDATE {$table} SET buyer = %i, touch = %i, closed = 1, pricesort = NULL WHERE row_id = %i";
     $rs = $this->execute($sql, $listing->buyer, $listing->touch, $row_id);
     // should have affected a row. if it didn't toss an exception.
     if ($rs->affected() < 1) {
         throw new Exception('failed', $this->db);
     }
 }
 /**
  * what is the item id of the currency, in stockpile?
  */
 protected function currencyId()
 {
     $id = $this->binder->currencyId();
     if (!Util::validatePositiveInteger($id)) {
         throw new Exception('invalid currency id', $id);
     }
     return $id;
 }
 /**
  * low level call to update a search vector cache key.
  */
 protected function updateSearchVector($key)
 {
     $this->cache(self::SEARCH_VECTOR_PREFIX)->set($key, Util::now() . '.' . mt_rand(1, 1000000000), 0);
 }