/** * this method returns a Propel ModelCriteria * * @return \Propel\Runtime\ActiveQuery\ModelCriteria */ public function buildModelCriteria() { $query = new PopInCampaignQuery(); if (null !== ($id = $this->getId())) { $query->filterById($id); } if (null !== ($content_source_type = $this->getContentSourceType())) { $content_source_type = array_map("trim", explode(",", $content_source_type)); $query->filterByContentSourceType($content_source_type); } if (null !== ($content_source_id = $this->getContentSourceId())) { $content_source_id = array_map("trim", explode(",", $content_source_id)); $query->filterByContentSourceId($content_source_id); } foreach ($this->getOrder() as $order) { switch ($order) { case "id": $query->orderById(); break; case "id-reverse": $query->orderById(Criteria::DESC); break; case "start": $query->orderByStart(); break; case "start-reverse": $query->orderByStart(Criteria::DESC); break; case "end": $query->orderByEnd(); break; case "end-reverse": $query->orderByEnd(Criteria::DESC); break; case "content_source_type": $query->orderByContentSourceType(); break; case "content_source_type-reverse": $query->orderByContentSourceType(Criteria::DESC); break; case "content_source_id": $query->orderByContentSourceId(); break; case "content_source_id-reverse": $query->orderByContentSourceId(Criteria::DESC); break; } } return $query; }
protected function getPopInCampaign(PopInCampaignEvent $event) { $model = PopInCampaignQuery::create()->findPk($event->getId()); if (null === $model) { throw new \RuntimeException(sprintf("The 'pop_in_campaign' id '%d' doesn't exist", $event->getId())); } return $model; }
/** * Get the currently running pop-in campaign (if any). * @return PopInCampaign|null */ protected static function getCurrentPopInCampaign() { $now = new \DateTime(); return PopInCampaignQuery::create()->where(PopInCampaignTableMap::START . Criteria::ISNULL)->_or()->where(PopInCampaignTableMap::START . Criteria::LESS_EQUAL . '?', $now)->_and()->where(PopInCampaignTableMap::END . Criteria::ISNULL)->_or()->where(PopInCampaignTableMap::END . Criteria::GREATER_EQUAL . '?', $now)->findOne(); }
/** * Removes this object from datastore and sets delete attribute. * * @param ConnectionInterface $con * @return void * @throws PropelException * @see PopInCampaign::setDeleted() * @see PopInCampaign::isDeleted() */ public function delete(ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection(PopInCampaignTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $deleteQuery = ChildPopInCampaignQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Load an existing object from the database */ protected function getExistingObject() { return PopInCampaignQuery::create()->findPk($this->getRequest()->query->get("pop_in_campaign_id")); }
/** * Performs an INSERT on the database, given a PopInCampaign or Criteria object. * * @param mixed $criteria Criteria or PopInCampaign object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(PopInCampaignTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from PopInCampaign object } if ($criteria->containsKey(PopInCampaignTableMap::ID) && $criteria->keyContainsValue(PopInCampaignTableMap::ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . PopInCampaignTableMap::ID . ')'); } // Set the correct dbName $query = PopInCampaignQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->beginTransaction(); $pk = $query->doInsert($con); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } return $pk; }