/** * gets the previous change if the action is 'modified' * * @return ConceptPropertyHistory object */ function getPrevious() { $propertyId = $this->getConceptPropertyId(); $timestamp = $this->getCreatedAt(); //build the query string $c = new Criteria(); $crit0 = $c->getNewCriterion(ConceptPropertyHistoryPeer::CONCEPT_PROPERTY_ID, $propertyId); $crit1 = $c->getNewCriterion(ConceptPropertyHistoryPeer::CREATED_AT, $timestamp, Criteria::LESS_THAN); // Perform AND at level 0 ($crit0 $crit1 ) $crit0->addAnd($crit1); $c->add($crit0); //set order and limits $c->setLimit(1); $c->addDescendingOrderByColumn(ConceptPropertyHistoryPeer::CREATED_AT); $result = ConceptPropertyHistoryPeer::doSelect($c); //return the resulting object if (count($result)) { $result = $result[0]; } return $result; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this SkosProperty has previously * been saved, it will retrieve related ConceptPropertyHistorys from storage. * If this SkosProperty is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getConceptPropertyHistorys($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseConceptPropertyHistoryPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collConceptPropertyHistorys === null) { if ($this->isNew()) { $this->collConceptPropertyHistorys = array(); } else { $criteria->add(ConceptPropertyHistoryPeer::SKOS_PROPERTY_ID, $this->getId()); ConceptPropertyHistoryPeer::addSelectColumns($criteria); $this->collConceptPropertyHistorys = ConceptPropertyHistoryPeer::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(ConceptPropertyHistoryPeer::SKOS_PROPERTY_ID, $this->getId()); ConceptPropertyHistoryPeer::addSelectColumns($criteria); if (!isset($this->lastConceptPropertyHistoryCriteria) || !$this->lastConceptPropertyHistoryCriteria->equals($criteria)) { $this->collConceptPropertyHistorys = ConceptPropertyHistoryPeer::doSelect($criteria, $con); } } } $this->lastConceptPropertyHistoryCriteria = $criteria; return $this->collConceptPropertyHistorys; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ 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(ConceptPropertyHistoryPeer::ID, $pks, Criteria::IN); $objs = ConceptPropertyHistoryPeer::doSelect($criteria, $con); } return $objs; }
/** * returns the last property history older than the supplied timestamp * * @return ConceptPropertyHistory * @param date $ts (optional) If null returns the latest */ public function getLastHistoryByTimestamp($ts = null) { $c = new Criteria(); $c->add(ConceptPropertyHistoryPeer::CONCEPT_PROPERTY_ID, $this->getId()); if ($ts) { $c->add(ConceptPropertyHistoryPeer::CREATED_AT, $ts, Criteria::LESS_EQUAL); } $c->addDescendingOrderByColumn(ConceptPropertyHistoryPeer::CREATED_AT); $c->setLimit(1); $result = ConceptPropertyHistoryPeer::doSelect($c); $result = count($result) == 1 ? $result[0] : false; return $result; }