Example #1
0
 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);
     }
 }