Пример #1
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     echo "Running sfReviewStatsTask ... \n";
     $query = "SELECT r.entity_id, r.sf_review_type_id, r.value, SUM(r.value) sum " . "FROM %s r " . "INNER JOIN %s s ON s.id = r.sf_review_status_id " . "WHERE r.is_active = 1 " . "AND r.sf_review_type_id is not null " . "group by entity_id, sf_review_type_id, value ";
     $query = sprintf($query, SfReviewPeer::TABLE_NAME, SfReviewStatusPeer::TABLE_NAME);
     $connection = Propel::getConnection();
     $statement = $connection->prepare($query);
     //$statement->bindValue(1, 0);
     $statement->execute();
     while ($row = $statement->fetch()) {
         $isNew = false;
         $yesterday = strtotime("yesterday");
         $sfReviewTypeEntity = SfReviewTypeEntityPeer::retrieveByPK($row['sf_review_type_id'], $row['entity_id'], $yesterday, $row['value']);
         if (!$sfReviewTypeEntity) {
             $isNew = true;
             $sfReviewTypeEntity = new SfReviewTypeEntity();
             $sfReviewTypeEntity->setSfReviewTypeId($row['sf_review_type_id']);
             $sfReviewTypeEntity->setEntityId($row['entity_id']);
             $sfReviewTypeEntity->setValue($row['value']);
             $sfReviewTypeEntity->setDate($yesterday);
             $sfReviewTypeEntity->setSum($row['sum']);
             SfReviewTypeEntityPeer::doInsert($sfReviewTypeEntity);
         }
     }
 }
Пример #2
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      SfReviewTypeEntity $value A SfReviewTypeEntity object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(SfReviewTypeEntity $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getSfReviewTypeId(), (string) $obj->getEntityId(), (string) $obj->getDate(), (string) $obj->getValue()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }