/** * Get the first record that matches the query. * * @param mixed $selectKeys * * @return ObjectModel|null */ public function first($selectKeys = null) { if ($selectKeys) { $this->parseQuery->select($selectKeys); } $data = $this->parseQuery->first($this->useMasterKey); if ($data) { return $this->createModel($data); } }
public function tasks() { $results = array(); $object = array(); $queryCrop = new ParseQuery("Crop"); $queryCrop->select("cropName"); $queryCrop->ascending("cropName"); $object = $queryCrop->find(); foreach ($object as $value) { array_push($results, $value->get('cropName')); } return view('tasks')->with("results", $results); }
public function maintenance() { $results = array(); $queryCropType = new ParseQuery("CropType"); $queryCropType->select("cropTypeDesc"); $queryCropType->ascending("cropTypeDesc"); $cropType = $queryCropType->find(); $results[0] = array(); //QUERY ALL CROP TYPE PARSE OBJECTS foreach ($cropType as $cType) { array_push($results[0], $cType->get('cropTypeDesc')); } $queryFertilizer = new ParseQuery("Fertilizer"); $fertilizer = $queryFertilizer->find(); $results[1] = array(); //QUERY ALL FERTILIZER TYPE PARSE OBJECTS foreach ($fertilizer as $fert) { array_push($results[1], $fert->get('fertilizerDesc')); } return view('maintenance')->with("results", $results); }
public function testSelectKeysQueryArrayArg() { $obj = ParseObject::create("TestObject"); $obj->set('foo', 'baz'); $obj->set('bar', 1); $obj->save(); $query = new ParseQuery("TestObject"); $query->select(['foo', 'bar']); $result = $query->first(); $this->assertEquals('baz', $result->get('foo'), 'Did not return the correct object.'); $this->assertEquals(1, $result->get('bar'), 'Did not return the correct object.'); }
public function getTimeZone() { // ParseInstallation.getCurrentInstallation().getString("_Installation"); $query = new ParseQuery('_Installation', true); try { $query->select("timeZone"); $results = $query->find(true); $array = array(); foreach ($results as $result) { $array[] = $result->get("timeZone"); } // die('<pre>'.print_r(array_unique($array))); return array_unique($array); } catch (ParseException $ex) { $ex_array = array("Status" => "FAILED", "Message" => $ex->getMessage(), "Code" => $ex->getCode()); return $ex_array; } return $results; }