public static function isNew($seriesName) { $c = new Criteria(); $c->add(SeriesPeer::SERIES_NAME, $seriesName, Criteria::EQUAL); $serieses = SeriesPeer::doSelect($c); if (count($serieses) > 0) { return false; } else { return true; } }
public function execute($request) { $brandId = $this->getRequestParameter('brand'); $query = $this->getRequestParameter('query'); //get series for this brand $cSeries = new Criteria(); if ($brandId) { $cSeries->add(SeriesPeer::BRAND_ID, $brandId); } $cSeries->add(SeriesPeer::SERIES_NAME, $query . '%', Criteria::LIKE); $cSeries->addGroupByColumn(SeriesPeer::SERIES_NAME); $cSeries->addAscendingOrderByColumn(SeriesPeer::SERIES_NAME); $cSeries->setLimit(15); $this->serieses = SeriesPeer::doSelect($cSeries); $this->getResponse()->setContentType('application/json'); }
public function executeListMoveDown(sfWebRequest $request) { $id = $request->getParameter('id'); $current = SeriesPeer::retrieveByPK($id); $items = SeriesPeer::doSelect(new Criteria()); for ($i = count($items) - 2; $i >= 0; $i--) { //echo $items[$i]; if ($items[$i]->getId() == $id) { $tmp = $items[$i + 1]->getWeight(); $items[$i + 1]->setWeight($tmp != $items[$i]->getWeight() ? $items[$i]->getWeight() : $items[$i]->getWeight() + 1); $items[$i]->setWeight($tmp); $items[$i]->save(); $items[$i + 1]->save(); break; } } $this->redirect('series'); }
public function executeGetSeries(sfWebRequest $request) { $c = new Criteria(); $c->add(SeriesPeer::BRAND_ID, $request->getGetParameter('brand_id')); $this->series = SeriesPeer::doSelect($c); }
/** * Gets an array of Series 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 Brand has previously been saved, it will retrieve * related Seriess from storage. If this Brand 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 Series[] * @throws PropelException */ public function getSeriess($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(BrandPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collSeriess === null) { if ($this->isNew()) { $this->collSeriess = array(); } else { $criteria->add(SeriesPeer::BRAND_ID, $this->id); SeriesPeer::addSelectColumns($criteria); $this->collSeriess = SeriesPeer::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(SeriesPeer::BRAND_ID, $this->id); SeriesPeer::addSelectColumns($criteria); if (!isset($this->lastSeriesCriteria) || !$this->lastSeriesCriteria->equals($criteria)) { $this->collSeriess = SeriesPeer::doSelect($criteria, $con); } } } $this->lastSeriesCriteria = $criteria; return $this->collSeriess; }
/** * 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(SeriesPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(SeriesPeer::DATABASE_NAME); $criteria->add(SeriesPeer::ID, $pks, Criteria::IN); $objs = SeriesPeer::doSelect($criteria, $con); } return $objs; }