/** * return all news generated by generator model and keys * * @param String generator_model - the PhpName of the model * @param String generator_keys - the primary keys (serialized, of the generator) * @return array of News * @author Guglielmo Celata **/ public static function getNewsGeneratedByGeneratorModelAndPrimaryKeys($generator_model, $generator_keys) { $c = new Criteria(); $c->add(NewsPeer::GENERATOR_MODEL, $generator_model); $c->add(NewsPeer::GENERATOR_PRIMARY_KEYS, $generator_keys); return NewsPeer::doSelect($c); }
public function executeNew(sfWebRequest $request) { $this->menu = MenuPeer::doSelect(new Criteria()); $c = new Criteria(); $c->add(PartsPeer::IS_ACTIVE, 1); $this->parts = PartsPeer::doSelect($c); unset($c); $id = $request->getParameter('id'); $c0 = new Criteria(); $c0->add(NewsPeer::IS_ACTIVE, 1); $c0->add(NewsPeer::ID, $id); $this->new = NewsPeer::doSelect($c0); $this->new = $this->new[0]; unset($c0); }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(NewsPeer::ID, $pks, Criteria::IN); $objs = NewsPeer::doSelect($criteria, $con); } return $objs; }
/** * get all the news in sf_news_cache, related to a given object * * @return array of News objects * @author Guglielmo Celata **/ function getRelatedNews($obj) { $c = new Criteria(); $c->add(NewsPeer::RELATED_MONITORABLE_MODEL, get_class($obj)); $c->add(NewsPeer::RELATED_MONITORABLE_ID, $obj->getPrimaryKey()); $related_news = NewsPeer::doSelect($c); return $related_news; }
<?php /* controlla le news che fanno riferimento a tag che non esistono e le cancella */ define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); $c = new Criteria(); $c->add(NewsPeer::RELATED_MONITORABLE_MODEL, 'Tag'); $news = NewsPeer::doSelect($c); foreach ($news as $n) { $tag = TagPeer::retrieveByPk($n->getRelatedMonitorableId()); if (!$tag) { echo "tag id=" . $n->getRelatedMonitorableId() . ", trovato nelle news id=" . $n->getId() . " non esiste. Cancello la news\n"; $n->delete(); } }
/** * Gets an array of News 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 Images has previously been saved, it will retrieve * related Newss from storage. If this Images 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 News[] * @throws PropelException */ public function getNewss($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ImagesPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNewss === null) { if ($this->isNew()) { $this->collNewss = array(); } else { $criteria->add(NewsPeer::IMAGES_ID, $this->id); NewsPeer::addSelectColumns($criteria); $this->collNewss = NewsPeer::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(NewsPeer::IMAGES_ID, $this->id); NewsPeer::addSelectColumns($criteria); if (!isset($this->lastNewsCriteria) || !$this->lastNewsCriteria->equals($criteria)) { $this->collNewss = NewsPeer::doSelect($criteria, $con); } } } $this->lastNewsCriteria = $criteria; return $this->collNewss; }
public function executeList() { $this->newss = NewsPeer::doSelect(new Criteria()); }
public function executeList() { $c = new Criteria(); $c->add(NewsPeer::PROJECT_ID, $this->getRequestParameter('project_id')); $this->newss = NewsPeer::doSelect($c); }