/** * Exclude object from result * * @param BuyListing $buyListing Object to remove from the list of results * * @return BuyListingQuery The current query, for fluid interface */ public function prune($buyListing = null) { if ($buyListing) { $this->addUsingAlias(BuyListingPeer::ID, $buyListing->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param BuyListing $obj A BuyListing object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null BuyListingPeer::$instances[$key] = $obj; } }
/** * Filter the query by a related BuyListing object * * @param BuyListing|PropelObjectCollection $buyListing the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ItemQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByBuyListing($buyListing, $comparison = null) { if ($buyListing instanceof BuyListing) { return $this->addUsingAlias(ItemPeer::DATA_ID, $buyListing->getItemId(), $comparison); } elseif ($buyListing instanceof PropelObjectCollection) { return $this->useBuyListingQuery()->filterByPrimaryKeys($buyListing->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByBuyListing() only accepts arguments of type BuyListing or PropelCollection'); } }
/** * @param BuyListing $buyListing The buyListing object to add. */ protected function doAddBuyListing($buyListing) { $this->collBuyListings[] = $buyListing; $buyListing->setItem($this); }
protected function updateListings($listings) { $now = new DateTime(); $item = ItemQuery::create()->findOneByDataId($listings['id']); $item->setLastUpdated($now); $sell = $listings['sells']; $buy = $listings['buys']; $lowestSell = null; $maxBuy = null; $sellQuantityAmount = 0; $sellListingsAmount = 0; if (count($sell)) { $lowestSell = min(array_map(function ($row) { return $row['unit_price']; }, $sell)); foreach ($sell as $s) { $sellQuantityAmount += $s['quantity']; $sellListingsAmount += $s['listings']; } } $sellListing = new SellListing(); $sellListing->setItem($item); $sellListing->setListingDatetime($now); $sellListing->setQuantity($sellQuantityAmount); $sellListing->setListings($sellListingsAmount); if ($lowestSell) { $sellListing->setUnitPrice($lowestSell); $item->setMinSaleUnitPrice($lowestSell); } else { $sellListing->setUnitPrice($item->getMinSaleUnitPrice()); } $item->setSaleAvailability($sellQuantityAmount); $sellListing->save(); $buyQuantityAmount = 0; $buyListingsAmount = 0; if (count($buy)) { $maxBuy = max(array_map(function ($row) { return $row['unit_price']; }, $buy)); foreach ($buy as $b) { $buyQuantityAmount += $b['quantity']; $buyListingsAmount += $b['listings']; } } $buyListing = new BuyListing(); $buyListing->setItem($item); $buyListing->setListingDatetime($now); $buyListing->setQuantity($buyQuantityAmount); $buyListing->setListings($buyListingsAmount); if ($maxBuy) { $buyListing->setUnitPrice($maxBuy); $item->setMaxOfferUnitPrice($maxBuy); } else { $buyListing->setUnitPrice($item->getMaxOfferUnitPrice()); } $item->setOfferAvailability($buyQuantityAmount); $buyListing->save(); $item->save(); }