/**
  * Retrieve object using using composite pkey values.
  * @param   int $id_event
  * @param   int $id_list
  * @param      PropelPDO $con
  * @return EventHasList
  */
 public static function retrieveByPK($id_event, $id_list, PropelPDO $con = null)
 {
     $_instancePoolKey = serialize(array((string) $id_event, (string) $id_list));
     if (null !== ($obj = EventHasListPeer::getInstanceFromPool($_instancePoolKey))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(EventHasListPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(EventHasListPeer::DATABASE_NAME);
     $criteria->add(EventHasListPeer::ID_EVENT, $id_event);
     $criteria->add(EventHasListPeer::ID_LIST, $id_list);
     $v = EventHasListPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
 /**
  * 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                 EventHasList A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id_event`, `id_list` FROM `event_has_list` WHERE `id_event` = :p0 AND `id_list` = :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)) {
         $obj = new EventHasList();
         $obj->hydrate($row);
         EventHasListPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
예제 #3
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = EventsPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related EventHasList objects
         $criteria = new Criteria(EventHasListPeer::DATABASE_NAME);
         $criteria->add(EventHasListPeer::ID_EVENT, $obj->getIdEvent());
         $affectedRows += EventHasListPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
예제 #4
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggregated array of ValidationFailed objects will be returned.
  *
  * @param array $columns Array of column names to validate.
  * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEvents !== null) {
             if (!$this->aEvents->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEvents->getValidationFailures());
             }
         }
         if ($this->aCustomLists !== null) {
             if (!$this->aCustomLists->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aCustomLists->getValidationFailures());
             }
         }
         if (($retval = EventHasListPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }