Exemplo n.º 1
0
 public static function add()
 {
     $keyword = $_POST['keyword'];
     $collection = MongoModel::getCollection(Keyword::collectionName);
     $collection->ensureIndex(array("str" => 1, "userSessionId" => 1));
     $keyword = array("str" => $keyword, "userSessionId" => $sessionId);
     $collection->save($keyword);
 }
Exemplo n.º 2
0
 public static function getKeywords($sessionId)
 {
     $collection = MongoModel::getCollection(Keyword::collectionName);
     $query = array("userSessionId" => $sessionId);
     $cursor = $collection->find($query);
     $keywordsList = array();
     while ($cursor->hasNext()) {
         $keywordsList[] = $cursor->getNext();
     }
     return $keywordsList;
 }
Exemplo n.º 3
0
Arquivo: User.php Projeto: amitamb/Red
 public static function getAll($sessionId)
 {
     $keyword = $_GET['keyword'];
     //print "astasxf";
     //print $sessionId;
     $collection = MongoModel::getCollection(Link::collectionName);
     $query = array("keyword" => $keyword, "userSessionId" => $sessionId);
     $cursor = $collection->find($query);
     $linksList = array();
     while ($cursor->hasNext()) {
         $linksList[] = $cursor->getNext();
     }
     return $linksList;
 }
Exemplo n.º 4
0
Arquivo: Link.php Projeto: amitamb/Red
 public static function getAllBySearchSessionId($sessionId, $searchSessionId)
 {
     // For $sesionId and searchSessionId
     // obtain all links
     $keyword = $_GET['keyword'];
     $collection = MongoModel::getCollection(Link::collectionName);
     $query = array("userSessionId" => $sessionId, "searchSessionId" => $searchSessionId);
     $cursor = $collection->find($query);
     $linksList = array();
     while ($cursor->hasNext()) {
         $linksList[] = $cursor->getNext();
     }
     return $linksList;
 }
Exemplo n.º 5
0
 public static function getAll($sessionId)
 {
     if (isset($_GET["sessionId"])) {
         // handle logic when sessionId is provided
     } else {
         $keyword = $_GET['keyword'];
         $query = $_GET['query'];
         $collection = MongoModel::getCollection(Session::collectionName);
         $query = array("keyword" => $keyword, "userSessionId" => $sessionId);
         $cursor = $collection->find($query);
         $linksList = array();
         while ($cursor->hasNext()) {
             $linksList[] = $cursor->getNext();
         }
         return $linksList;
     }
 }
Exemplo n.º 6
0
 /**
  * Set property value and save data.
  *
  * @param string $key
  * @param mixed $value
  */
 public function set($key, $value)
 {
     parent::set($key, $value);
     $this->save();
 }
Exemplo n.º 7
0
 public function __construct()
 {
     parent::__construct();
 }
Exemplo n.º 8
0
 public static function collection($name = null)
 {
     return MongoModel::db()->{$name ?: static::$collection};
 }
function mongo($name)
{
    $m = new MongoModel();
    return $m->setConnect($name);
}
Exemplo n.º 10
0
 /**
  * Initialize MongoAutoIncrement instance.
  *
  * @param mixed $value
  * @throws \Exception
  */
 public function __construct($value = null)
 {
     self::_setDbCollection();
     parent::__construct($value);
 }
 function update($id, $fields, $tableName = null)
 {
     $this->setCurrentVersion();
     $versions = $this->getVersions($id, $tableName);
     $versions[$this->version] = time();
     ksort($versions);
     $versions[$this->useIndex] = $id;
     parent::create($versions, $tableName);
     $fields[$this->useIndex] = $id . '~' . $this->version;
     parent::create($fields, $tableName);
 }