Example #1
0
 public function __construct()
 {
     $this->_mongo = DBConnection::instantiate();
     $this->_collection = $this->_mongo->getCollection(User::COLLECTON);
     if ($this->isLoggedIn()) {
         $this->_loadData();
     }
 }
 public function __construct($id = null)
 {
     $this->_mysql = getMySQLConnection();
     $this->_mongodb = DBConnection::instantiate();
     $this->_collection = $this->_mongodb->getCollection('customer_metadata');
     $this->_table = 'customers';
     if (isset($id)) {
         $this->_id = $id;
         $this->_load();
     }
 }
Example #3
0
 public function __construct()
 {
     $this->_mongo = DBConnection::instantiate();
     $this->_collection = $this->_mongo->getCollection(SessionManager::COLLECTION);
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     // configura periodo recolección de basura
     ini_set('session.gc_maxlifetime', SessionManager::SESSION_LIFESPAN);
     session_set_cookie_params(SessionManager::SESSION_LIFESPAN, SessionManager::SESSION_COOKIE_PATH, SessionManager::SESSION_COOKIE_DOMAIN);
     session_name(SessionManager::SESSION_NAME);
     session_cache_limiter('nocache');
     session_start();
 }
 public function __construct()
 {
     $this->_mongo = DBConnection::instantiate();
     $this->_collection = $this->_mongo->getCollection(SessionManager::COLLECTION);
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     //Set session garbage collection period
     ini_set('session.gc_maxlifetime', SessionManager::SESSION_LIFESPAN);
     //set session cookie configurations
     session_set_cookie_params(SessionManager::SESSION_LIFESPAN, SessionManager::SESSION_COOKIE_PATH, SessionManager::SESSION_COOKIE_DOMAIN);
     //Replace 'PHPSESSID' with 'mongosessid' as the
     //session name
     session_name(SessionManager::SESSION_NAME);
     session_cache_limiter('nocache');
     //start the session
     session_start();
 }
<?php

require 'dbconnection.php';
$mongo = DBConnection::instantiate();
$collection = $mongo->getCollection('sample_articles');
$key = array('author' => 1);
$initial = array('count' => 0, 'total_rating' => 0);
$reduce = "function(obj, counter) { counter.count++; counter.total_rating += obj.rating;}";
$finalize = "function(counter) { counter.avg_rating = Math.round(counter.total_rating / counter.count); }";
$condition = array('published_at' => array('$gte' => new MongoDate(strtotime('-1 day'))));
$result = $collection->group($key, $initial, new MongoCode($reduce), array('finalize' => new MongoCode($finalize), 'condition' => $condition));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>Author Rating</title> 
        <link rel="stylesheet" href="style.css"/>

    </head>
    <body>
        <div id="contentarea">
            <div id="innercontentarea">
                <h1>Authors' Ratings</h1>
                <table class="table-list" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th width="50%">Author</th>
                            <th width="24%">Articles</th>
                            <th width="*">Average Rating</th>
                        </tr>
<?php

require 'dbconnection.php';
$dbConnection = DBConnection::instantiate();
$collection = $dbConnection->getCollection('article_visit_counter_daily');
function getArticleTitle($id)
{
    global $dbConnection;
    $article = $dbConnection->getCollection('articles')->findOne(array('_id' => new MongoId($id)));
    return $article['title'];
}
$objects = $collection->find(array('request_date' => new MongoDate(strtotime('today'))));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>Daily Page views (in realtime)</title> 
        <link rel="stylesheet" href="style.css"/>
        <style type="text/css" media="screen">
            body { font-size: 13px; }
            div#contentarea { width : 680px; }
        </style>
    </head>
    <body>
        <div id="contentarea">
            <div id="innercontentarea">
                <h1>Daily Page views (in realtime)</h1>
                <table class="articles" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
 public function __construct()
 {
     $this->_dbconnection = DBConnection::instantiate();
     $this->_collection = $this->_dbconnection->getCollection(LOGNAME);
 }