public function execute() { $this->forceSystemAuthentication(); $start = microtime(true); $limit = 7; // new partners $c = new Criteria(); $this->partner_count = PartnerPeer::doCount($c); // count before setting the limit $c->setLimit($limit); $c->addDescendingOrderByColumn(PartnerPeer::CREATED_AT); $newest_partners = PartnerPeer::doSelect($c); // $new_partners_ids = self::getIds( $new_partners ); // fetch stats for these partners // TODO - if new - what statistics could it have ?? // fdb::populateObjects( $newest_partners , new PartnerStatsPeer() , "id" , "partnerStats" , false ,"partnerId"); $exclude = $this->getP("exclude"); if ($exclude) { self::addToExceludeList($exclude); } $exclude_list = self::getExceludeList(); // most viewed $c = new Criteria(); $c->add(PartnerStatsPeer::PARTNER_ID, $exclude_list, Criteria::NOT_IN); $c->setLimit($limit); $c->addDescendingOrderByColumn(PartnerStatsPeer::VIEWS); $stats_most_views = PartnerStatsPeer::doSelect($c); $most_views = self::getPartnerListFromStats($stats_most_views); // most entries $c = new Criteria(); $c->add(PartnerStatsPeer::PARTNER_ID, $exclude_list, Criteria::NOT_IN); $c->setLimit($limit); $c->addDescendingOrderByColumn(PartnerStatsPeer::ENTRIES); $stats_most_entries = PartnerStatsPeer::doSelect($c); $most_entries = self::getPartnerListFromStats($stats_most_entries); $end = microtime(true); $this->newest_partners = $newest_partners; $this->most_views = $most_views; $this->most_entries = $most_entries; $this->bench = $end - $start; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PartnerStatsPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setPartnerId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setViews($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setPlays($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setVideos($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setAudios($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setImages($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setEntries($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setUsers1($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setUsers2($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setRc1($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setRc2($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setKshows1($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setKshows2($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setCreatedAt($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setUpdatedAt($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setCustomData($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setWidgets($arr[$keys[16]]); } }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = new Criteria(PartnerStatsPeer::DATABASE_NAME); $criteria->add(PartnerStatsPeer::PARTNER_ID, $this->partner_id); if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(PartnerStatsPeer::UPDATED_AT)) { $theModifiedColumn = null; foreach ($this->modifiedColumns as $modifiedColumn) { if ($modifiedColumn != PartnerStatsPeer::UPDATED_AT) { $theModifiedColumn = $modifiedColumn; } } $atomicColumns = PartnerStatsPeer::getAtomicColumns(); if (in_array($theModifiedColumn, $atomicColumns)) { $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL); } } return $criteria; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(PartnerStatsPeer::DATABASE_NAME); $criteria->add(PartnerStatsPeer::PARTNER_ID, $pks, Criteria::IN); $objs = PartnerStatsPeer::doSelect($criteria, $con); } return $objs; }