public function testSetWhere() { $push = new LeanPush(array("alert" => "Hello world!")); $query = new LeanQuery("_Installation"); $date = new DateTime(); $query->lessThan("updatedAt", $date); $push->setWhere($query); $out = $push->encode(); $this->assertEquals(array("updatedAt" => array('$lt' => LeanClient::encode($date))), $out["where"]); }
public function query() { echo $iddd; //try { //throw new \Exception('nima'); // } catch (\Exception $e) { // echo 1234; // } $query = new LeanQuery("TestObject"); $objects = $query->find(); foreach ($objects as $v) { var_dump($v->get('objectId')); var_dump($v->get('name')); } //var_dump($objects); }
public function testComposeCompexLogicalQuery() { $q1 = new LeanQuery("TestObject"); $q1->greaterThanOrEqualTo("number", 42); $q2 = new LeanQuery("TestObject"); $q2->lessThan("number", 24); $q3 = new LeanQuery("TestObject"); $q3->contains("title", "clojure"); $q = LeanQuery::orQuery($q1, $q2); $out = $q->encode(); $where = array('$or' => array(array("number" => array('$gte' => 42)), array("number" => array('$lt' => 24)))); $this->assertEquals(json_encode($where), $out["where"]); $q = LeanQuery::andQuery($q, $q3); $out = $q->encode(); $where = array('$and' => array(array('$or' => array(array("number" => array('$gte' => 42)), array("number" => array('$lt' => 24)))), array("title" => array('$regex' => "clojure")))); $this->assertEquals(json_encode($where), $out["where"]); }
/** * Not-match values of specified field from a sub-query * * @param string $key * @param string $queryKey Target field key in sub-query * @param LeanQuery $query The sub-query * @return self */ public function notMatchFieldInQuery($key, $queryKey, $query) { $this->_addCondition($key, '$dontSelect', array("key" => $queryKey, "query" => array("where" => $query->where, "className" => $query->getClassName()))); return $this; }
/** * Query on the parent class where child is in the relation * * @param LeanObject $child Child object * @return LeanQuery */ public function getReverseQuery(LeanObject $child) { $query = new LeanQuery($this->parent->getClassName()); $query->equalTo($this->key, $child->getPointer()); return $query; }
public function testFindUserWithSession() { $user = LeanUser::logIn("alice", "blabla"); $query = new LeanQuery("_User"); // it should not raise: 1 Forbidden to find by class permission. $query->first(); }
public function testDoCloudQueryWithPvalues() { $obj = new LeanObject("TestObject"); $obj->set("name", "alice"); $obj->save(); $resp = LeanQuery::doCloudQuery("SELECT * FROM TestObject " . "WHERE name = ? LIMIT ?", array("alice", 1)); $this->assertGreaterThan(0, count($resp["results"])); $obj->destroy(); }