public function executeRightBox() { $category = $this->getRequestParameter('category'); $c = new Criteria(); $c->add(ItemPeer::IS_ACTIVE, true); $c->addDescendingOrderByColumn(ItemPeer::CREATED_AT); if ($category) { $c->add(ItemPeer::ITEM_TYPE_ID, $category); } $this->items = ItemPeer::doSelect($c); $this->itemTypes = ItemTypePeer::doSelect(new Criteria()); $this->user = $this->getUser()->getRaykuUser(); }
/** * Executes itemDetail action * */ public function executeItemDetail() { $id = $this->getRequestParameter('id'); $this->user = $this->getUser()->getRaykuUser(); $this->item = ItemPeer::retrieveByPK($id); $total_item_price = $this->item->getPricePerUnit() + $this->item->getShippingChargePerunit(); if ($this->getUser()->getRaykuUser()->getPoints() < $total_item_price) { $this->msg = 'Sorry! Not enough RP!'; } else { $this->msg = ''; } $c = new Criteria(); $c->add(ItemRatingPeer::ITEM_ID, $this->item->getId()); $item_ratings = ItemRatingPeer::doSelect($c); $this->countReviews = count($item_ratings); $rating = 0; foreach ($item_ratings as $item_rating) { $rating = $rating + $item_rating->getRating(); } $c = new Criteria(); $c->add(ItemPeer::IS_ACTIVE, true); $c->addDescendingOrderByColumn(ItemPeer::CREATED_AT); $c->add(ItemPeer::ID, $this->item->getId(), Criteria::NOT_EQUAL); $this->other_items = ItemPeer::doSelect($c); $this->avgRating = $rating > 0 && count($item_ratings) > 0 ? (int) ($rating / count($item_ratings)) : 0; $features = $this->item->getFeatures(); if ($features && trim($features) != '') { $this->features = explode(',', $features); } else { $this->features = ''; } $c = new Criteria(); $c->add(ItemRatingPeer::ITEM_ID, $id); $c->add(ItemRatingPeer::USER_ID, $this->user->getId()); $item_rating = ItemRatingPeer::doSelect($c); if ($item_rating) { $this->allowRate = false; } else { $this->allowRate = true; } //this protoype script is put in response for rating compatibility $this->getResponse()->addJavascript('/sf/prototype/js/prototype'); $this->getResponse()->addJavascript('prototype'); $this->getResponse()->addJavascript('protorater'); }
public function executeIndex(sfWebRequest $request) { $this->Items = ItemPeer::doSelect(new Criteria()); }
/** * Gets an array of Item objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this Feed has previously been saved, it will retrieve * related Items from storage. If this Feed is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array Item[] * @throws PropelException */ public function getItems($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(FeedPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collItems === null) { if ($this->isNew()) { $this->collItems = array(); } else { $criteria->add(ItemPeer::FEED_ID, $this->id); ItemPeer::addSelectColumns($criteria); $this->collItems = ItemPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(ItemPeer::FEED_ID, $this->id); ItemPeer::addSelectColumns($criteria); if (!isset($this->lastItemCriteria) || !$this->lastItemCriteria->equals($criteria)) { $this->collItems = ItemPeer::doSelect($criteria, $con); } } } $this->lastItemCriteria = $criteria; return $this->collItems; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ItemPeer::DATABASE_NAME); $criteria->add(ItemPeer::ID, $pks, Criteria::IN); $objs = ItemPeer::doSelect($criteria, $con); } return $objs; }
/** * Retrieve object using using composite pkey values. * @param int $id_item @param int $id_formulario * @param PropelPDO $con * @return Item */ public static function retrieveByPK($id_item, $id_formulario, PropelPDO $con = null) { $key = serialize(array((string) $id_item, (string) $id_formulario)); if (null !== ($obj = ItemPeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(ItemPeer::DATABASE_NAME); $criteria->add(ItemPeer::ID_ITEM, $id_item); $criteria->add(ItemPeer::ID_FORMULARIO, $id_formulario); $v = ItemPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
/** * The unit test assumes that sfGuardPlugin is installed and that the model * class Item is defined. */ include dirname(__FILE__) . '/../bootstrap/unit.php'; sfPropelBehavior::add('sfGuardUser', array('sfPropelActAsSlopeOneRaterBehavior')); //Setup values sfRatingPeer::doDeleteAll(); sfGuardUserPeer::doDeleteAll(); $users = array(); for ($i = 0; $i < 3; $i++) { $users[$i] = new sfGuardUser(); $users[$i]->setUsername(rand()); $users[$i]->save(); } $items = ItemPeer::doSelect(new Criteria()); $items[0]->setRating(5, $users[0]->getId()); $items[1]->setRating(3, $users[0]->getId()); $items[2]->setRating(2, $users[0]->getId()); $items[0]->setRating(3, $users[1]->getId()); $items[1]->setRating(4, $users[1]->getId()); $items[1]->setRating(2, $users[2]->getId()); $items[2]->setRating(5, $users[2]->getId()); $t = new lime_test(10, new lime_output_color()); //Build slope one tables foreach (array('sfPropelSlopeOnePhpBuilder', 'sfPropelSlopeOneMySqlBuilder') as $builder) { $builder = new $builder(new sfPropelSlopeOneSqlParser()); $builder->build(); $t->is(sfSlopeOnePeer::doCount(new Criteria()), sizeof($items) * (sizeof($items) - 1), 'Correct number of slope one values generated using ' . get_class($builder)); } $t->is(sizeof($items[0]->getRecommendations()), sizeof($items) - 1, 'Correct number of recommendations retrieved for item');
public function getItemsFormularios() { $c = new Criteria(); $c->addJoin(ItemPeer::ID_FORMULARIO, FormularioPeer::ID_FORMULARIO); $c->addJoin(FormularioPeer::ID_TABLA, TablaPeer::ID_TABLA); $c->add(TablaPeer::ID_TABLA, $this->getIdTabla()); $items = ItemPeer::doSelect($c); return $items; }