예제 #1
0
파일: CommonLink.php 프로젝트: amitamb/Red
 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);
 }
예제 #2
0
파일: Keyword.php 프로젝트: amitamb/Red
 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;
 }
예제 #3
0
파일: User.php 프로젝트: 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;
 }
예제 #4
0
파일: Link.php 프로젝트: 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;
 }
예제 #5
0
파일: Session.php 프로젝트: amitamb/Red
 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;
     }
 }
예제 #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();
 }
예제 #7
0
파일: TestMongo.php 프로젝트: jceee/ikaros
 public function __construct()
 {
     parent::__construct();
 }
예제 #8
0
 public static function collection($name = null)
 {
     return MongoModel::db()->{$name ?: static::$collection};
 }
function mongo($name)
{
    $m = new MongoModel();
    return $m->setConnect($name);
}
예제 #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);
 }