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); }
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; }
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; }
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; }
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; } }
/** * Set property value and save data. * * @param string $key * @param mixed $value */ public function set($key, $value) { parent::set($key, $value); $this->save(); }
public function __construct() { parent::__construct(); }
public static function collection($name = null) { return MongoModel::db()->{$name ?: static::$collection}; }
function mongo($name) { $m = new MongoModel(); return $m->setConnect($name); }
/** * 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); }