deblan.tv/vendor/trinity/src/Trinity/Bundle/NewsletterBundle/Model/om/BaseNewsletterRecipientsQuery.php
2015-03-02 21:57:49 +01:00

582 lines
24 KiB
PHP

<?php
namespace Trinity\Bundle\NewsletterBundle\Model\om;
use \Criteria;
use \Exception;
use \ModelCriteria;
use \ModelJoin;
use \PDO;
use \Propel;
use \PropelCollection;
use \PropelException;
use \PropelObjectCollection;
use \PropelPDO;
use FOS\UserBundle\Propel\Group;
use Glorpen\Propel\PropelBundle\Dispatcher\EventDispatcherProxy;
use Glorpen\Propel\PropelBundle\Events\QueryEvent;
use Trinity\Bundle\NewsletterBundle\Model\Newsletter;
use Trinity\Bundle\NewsletterBundle\Model\NewsletterRecipients;
use Trinity\Bundle\NewsletterBundle\Model\NewsletterRecipientsPeer;
use Trinity\Bundle\NewsletterBundle\Model\NewsletterRecipientsQuery;
/**
* @method NewsletterRecipientsQuery orderByNwsNewsletterId($order = Criteria::ASC) Order by the nws_newsletter_id column
* @method NewsletterRecipientsQuery orderByFosGroupId($order = Criteria::ASC) Order by the fos_group_id column
*
* @method NewsletterRecipientsQuery groupByNwsNewsletterId() Group by the nws_newsletter_id column
* @method NewsletterRecipientsQuery groupByFosGroupId() Group by the fos_group_id column
*
* @method NewsletterRecipientsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method NewsletterRecipientsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method NewsletterRecipientsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method NewsletterRecipientsQuery leftJoinNewsletter($relationAlias = null) Adds a LEFT JOIN clause to the query using the Newsletter relation
* @method NewsletterRecipientsQuery rightJoinNewsletter($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Newsletter relation
* @method NewsletterRecipientsQuery innerJoinNewsletter($relationAlias = null) Adds a INNER JOIN clause to the query using the Newsletter relation
*
* @method NewsletterRecipientsQuery leftJoinGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the Group relation
* @method NewsletterRecipientsQuery rightJoinGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Group relation
* @method NewsletterRecipientsQuery innerJoinGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the Group relation
*
* @method NewsletterRecipients findOne(PropelPDO $con = null) Return the first NewsletterRecipients matching the query
* @method NewsletterRecipients findOneOrCreate(PropelPDO $con = null) Return the first NewsletterRecipients matching the query, or a new NewsletterRecipients object populated from the query conditions when no match is found
*
* @method NewsletterRecipients findOneByNwsNewsletterId(int $nws_newsletter_id) Return the first NewsletterRecipients filtered by the nws_newsletter_id column
* @method NewsletterRecipients findOneByFosGroupId(int $fos_group_id) Return the first NewsletterRecipients filtered by the fos_group_id column
*
* @method array findByNwsNewsletterId(int $nws_newsletter_id) Return NewsletterRecipients objects filtered by the nws_newsletter_id column
* @method array findByFosGroupId(int $fos_group_id) Return NewsletterRecipients objects filtered by the fos_group_id column
*/
abstract class BaseNewsletterRecipientsQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseNewsletterRecipientsQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = null, $modelName = null, $modelAlias = null)
{
if (null === $dbName) {
$dbName = 'default';
}
if (null === $modelName) {
$modelName = 'Trinity\\Bundle\\NewsletterBundle\\Model\\NewsletterRecipients';
}
parent::__construct($dbName, $modelName, $modelAlias);
EventDispatcherProxy::trigger(array('construct','query.construct'), new QueryEvent($this));
}
/**
* Returns a new NewsletterRecipientsQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param NewsletterRecipientsQuery|Criteria $criteria Optional Criteria to build the query from
*
* @return NewsletterRecipientsQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof NewsletterRecipientsQuery) {
return $criteria;
}
$query = new static(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array $key Primary key to use for the query
A Primary key composition: [$nws_newsletter_id, $fos_group_id]
* @param PropelPDO $con an optional connection object
*
* @return NewsletterRecipients|NewsletterRecipients[]|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = NewsletterRecipientsPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(NewsletterRecipientsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con A connection object
*
* @return NewsletterRecipients A model object, or null if the key is not found
* @throws PropelException
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `nws_newsletter_id`, `fos_group_id` FROM `nws_newsletter_recipients` WHERE `nws_newsletter_id` = :p0 AND `fos_group_id` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
}
$obj = null;
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$cls = NewsletterRecipientsPeer::getOMClass();
$obj = new $cls;
$obj->hydrate($row);
NewsletterRecipientsPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con A connection object
*
* @return NewsletterRecipients|NewsletterRecipients[]|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param PropelPDO $con an optional connection object
*
* @return PropelObjectCollection|NewsletterRecipients[]|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(NewsletterRecipientsPeer::FOS_GROUP_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the nws_newsletter_id column
*
* Example usage:
* <code>
* $query->filterByNwsNewsletterId(1234); // WHERE nws_newsletter_id = 1234
* $query->filterByNwsNewsletterId(array(12, 34)); // WHERE nws_newsletter_id IN (12, 34)
* $query->filterByNwsNewsletterId(array('min' => 12)); // WHERE nws_newsletter_id >= 12
* $query->filterByNwsNewsletterId(array('max' => 12)); // WHERE nws_newsletter_id <= 12
* </code>
*
* @see filterByNewsletter()
*
* @param mixed $nwsNewsletterId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function filterByNwsNewsletterId($nwsNewsletterId = null, $comparison = null)
{
if (is_array($nwsNewsletterId)) {
$useMinMax = false;
if (isset($nwsNewsletterId['min'])) {
$this->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $nwsNewsletterId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($nwsNewsletterId['max'])) {
$this->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $nwsNewsletterId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $nwsNewsletterId, $comparison);
}
/**
* Filter the query on the fos_group_id column
*
* Example usage:
* <code>
* $query->filterByFosGroupId(1234); // WHERE fos_group_id = 1234
* $query->filterByFosGroupId(array(12, 34)); // WHERE fos_group_id IN (12, 34)
* $query->filterByFosGroupId(array('min' => 12)); // WHERE fos_group_id >= 12
* $query->filterByFosGroupId(array('max' => 12)); // WHERE fos_group_id <= 12
* </code>
*
* @see filterByGroup()
*
* @param mixed $fosGroupId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function filterByFosGroupId($fosGroupId = null, $comparison = null)
{
if (is_array($fosGroupId)) {
$useMinMax = false;
if (isset($fosGroupId['min'])) {
$this->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $fosGroupId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($fosGroupId['max'])) {
$this->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $fosGroupId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $fosGroupId, $comparison);
}
/**
* Filter the query by a related Newsletter object
*
* @param Newsletter|PropelObjectCollection $newsletter The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
public function filterByNewsletter($newsletter, $comparison = null)
{
if ($newsletter instanceof Newsletter) {
return $this
->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $newsletter->getId(), $comparison);
} elseif ($newsletter instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID, $newsletter->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByNewsletter() only accepts arguments of type Newsletter or PropelCollection');
}
}
/**
* Adds a JOIN clause to the query using the Newsletter relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function joinNewsletter($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Newsletter');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Newsletter');
}
return $this;
}
/**
* Use the Newsletter relation Newsletter object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Trinity\Bundle\NewsletterBundle\Model\NewsletterQuery A secondary query class using the current class as primary query
*/
public function useNewsletterQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinNewsletter($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Newsletter', '\Trinity\Bundle\NewsletterBundle\Model\NewsletterQuery');
}
/**
* Filter the query by a related Group object
*
* @param Group|PropelObjectCollection $group The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
public function filterByGroup($group, $comparison = null)
{
if ($group instanceof Group) {
return $this
->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $group->getId(), $comparison);
} elseif ($group instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(NewsletterRecipientsPeer::FOS_GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
}
}
/**
* Adds a JOIN clause to the query using the Group relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Group');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Group');
}
return $this;
}
/**
* Use the Group relation Group object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \FOS\UserBundle\Propel\GroupQuery A secondary query class using the current class as primary query
*/
public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinGroup($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Group', '\FOS\UserBundle\Propel\GroupQuery');
}
/**
* Exclude object from result
*
* @param NewsletterRecipients $newsletterRecipients Object to remove from the list of results
*
* @return NewsletterRecipientsQuery The current query, for fluid interface
*/
public function prune($newsletterRecipients = null)
{
if ($newsletterRecipients) {
$this->addCond('pruneCond0', $this->getAliasedColName(NewsletterRecipientsPeer::NWS_NEWSLETTER_ID), $newsletterRecipients->getNwsNewsletterId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(NewsletterRecipientsPeer::FOS_GROUP_ID), $newsletterRecipients->getFosGroupId(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Code to execute before every SELECT statement
*
* @param PropelPDO $con The connection object used by the query
*/
protected function basePreSelect(PropelPDO $con)
{
// event behavior
EventDispatcherProxy::trigger('query.select.pre', new QueryEvent($this));
return $this->preSelect($con);
}
/**
* Code to execute before every DELETE statement
*
* @param PropelPDO $con The connection object used by the query
*/
protected function basePreDelete(PropelPDO $con)
{
// event behavior
EventDispatcherProxy::trigger(array('delete.pre','query.delete.pre'), new QueryEvent($this));
return $this->preDelete($con);
}
/**
* Code to execute after every DELETE statement
*
* @param int $affectedRows the number of deleted rows
* @param PropelPDO $con The connection object used by the query
*/
protected function basePostDelete($affectedRows, PropelPDO $con)
{
// event behavior
EventDispatcherProxy::trigger(array('delete.post','query.delete.post'), new QueryEvent($this));
return $this->postDelete($affectedRows, $con);
}
/**
* Code to execute before every UPDATE statement
*
* @param array $values The associative array of columns and values for the update
* @param PropelPDO $con The connection object used by the query
* @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects
*/
protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
{
// event behavior
EventDispatcherProxy::trigger(array('update.pre', 'query.update.pre'), new QueryEvent($this));
return $this->preUpdate($values, $con, $forceIndividualSaves);
}
/**
* Code to execute after every UPDATE statement
*
* @param int $affectedRows the number of updated rows
* @param PropelPDO $con The connection object used by the query
*/
protected function basePostUpdate($affectedRows, PropelPDO $con)
{
// event behavior
EventDispatcherProxy::trigger(array('update.post', 'query.update.post'), new QueryEvent($this));
return $this->postUpdate($affectedRows, $con);
}
// extend behavior
public function setFormatter($formatter)
{
if (is_string($formatter) && $formatter === \ModelCriteria::FORMAT_ON_DEMAND) {
$formatter = '\Glorpen\Propel\PropelBundle\Formatter\PropelOnDemandFormatter';
}
return parent::setFormatter($formatter);
}
}