?> <?php } ?> <?php echo link_to($user->getName(), 'http://' . RaykuCommon::getCurrentHttpDomain() . '/tutor/' . $user->getUsername(), array('class' => 'username')); ?> </div> <div class="points" style="font-weight:normal;color:#666">Posts: <strong><?php $logedUserId = $user->getID(); $v = new Criteria(); $v->add(PostPeer::POSTER_ID, $logedUserId); $_postCount = PostPeer::doCount($v); echo $_postCount; ?> </strong> </div> <div class="points" style="font-weight:normal;color:#666;margin-top:4px;">RP: <strong><?php $query = mysql_query("select * from user where id=" . $logedUserId . " ", $connection) or die(mysql_error()); $detailPoints = mysql_fetch_assoc($query); echo $detailPoints['points']; ?> </strong> </div> <?php $query_es = mysql_query("select * from user_score where user_id=" . $detailPoints[id] . " ", $connection) or die(mysql_error()); $es_score = mysql_fetch_assoc($query_es);
if ($pos === false) { echo substr($post->getContent(),0,50); } else { echo " "; }*/ ?> </div> </div> <?php echo link_to($user->getUsername(), '@profile?username='******'class' => 'author')); ?> <?php $c = new Criteria(); $c->add(PostPeer::THREAD_ID, $thread->getId()); $countofpost = PostPeer::doCount($c); ?> <div class="replies"> <?php echo $countofpost - 1; ?> Replies</div> <div class="spacer"></div> </div> <?php } } //end if ?> </div> <div class="spacer"></div>
public function executeStats() { $stats = array(); $c = new Criteria(); // readers_cnt $date = date('Y-m-d', strtotime('-1 day')); $c->clear(); $c->add(ReaderPeer::DATE, $date); $readers = ReaderPeer::doSelectOne($c); $cnt = $readers ? $readers->getCnt() : 0; $tcnt = $cnt % 100; $str = ''; if ($tcnt == 1) { $str = 'osoba'; } else { if ($tcnt >= 12 && $tcnt <= 14) { $str = 'osób'; } else { if ($tcnt % 10 > 1 && $tcnt % 10 < 5) { $str = 'osoby'; } else { $str = 'osób'; } } } $stats['reader_cnt'] = $cnt == 0 ? 'brak danych' : sprintf('%d %s', $cnt, $str); // blog_cnt $c->clear(); $c->add(BlogPeer::APPROVED, true); $stats['blog_cnt'] = BlogPeer::doCount($c); // post_cnt $c->clear(); $c->add(PostPeer::DELETED, false); $stats['post_cnt'] = PostPeer::doCount($c); // month_avg $c->clear(); $c->addAscendingOrderByColumn(PostPeer::CREATED_AT); $post = PostPeer::doSelectOne($c); $ots = $post ? $post->getCreatedAt(null) : time(); $years = date('Y') - date('Y', $ots); $months = $years * 12 + (date('n') - date('n', $ots)); $stats['month_avg'] = $months > 0 ? round($stats['post_cnt'] / $months) : 0; // assign $this->stats = $stats; }
/** * Returns the number of related Posts. * * @param Criteria $criteria * @param boolean $distinct * @param Connection $con * @throws PropelException */ public function countPosts($criteria = null, $distinct = false, $con = null) { // include the Peer class include_once 'lib/model/om/BasePostPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(PostPeer::BLOG_ID, $this->getId()); return PostPeer::doCount($criteria, $distinct, $con); }
<?php $c = new Criteria(); $c->add(UserPeer::TYPE, '5'); $c->addDescendingOrderByColumn(UserPeer::POINTS); $c->setLimit(10); $experts = UserPeer::doSelect($c); ?> <ul class="experts"> <?php foreach ($experts as $expert) { ?> <?php $c = new Criteria(); $c->add(PostPeer::POSTER_ID, $expert->getId()); $c->add(PostPeer::BEST_RESPONSE, '1'); $best_resp = PostPeer::doCount($c); ?> <li><?php echo link_to($expert->getName(), sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $expert->getUsername()); ?> : <?php echo $best_resp; ?> Best Responses</li> <?php } ?> </ul> </div> <div class="bot"></div> </div>-->
static function getCountOfBestResponseForCreatedThreadsByUser($user) { $c = new Criteria(); $c->add(ThreadPeer::POSTER_ID, $user->getId()); $c->addJoin(PostPeer::THREAD_ID, ThreadPeer::ID, Criteria::JOIN); $c->add(PostPeer::BEST_RESPONSE, 1); return PostPeer::doCount($c); }