本文整理汇总了PHP中Parse\ParseQuery::first方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseQuery::first方法的具体用法?PHP ParseQuery::first怎么用?PHP ParseQuery::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseQuery
的用法示例。
在下文中一共展示了ParseQuery::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auth
/**
* Handles authentication via estonian id-card. Saves data into model User.
*/
public function auth()
{
$ePerson = getEPerson();
if (!$ePerson) {
// TODO: Better handling
$this->user->string = "ID kaardiga autentimine ebaõnnestus!";
} else {
$this->user->lastName = $ePerson[0];
$this->user->firstName = $ePerson[1];
$this->user->nationalID = $ePerson[2];
$this->user->string = "ID kaardiga autentimine õnnestus edukalt!";
// Check if UserObject already exists
// TODO: Put following code into separate function
$query = new ParseQuery("UserObject");
$query->equalTo("nationalID", $this->user->nationalID);
$count = $query->count();
$parseUser = $query->first();
if ($count == 1 && $parseUser->get('nationalID') == $this->user->nationalID) {
$this->user->parseMessage = $parseUser->getObjectId();
} else {
$this->saveUserData($this->user, $this->user->lastName, $this->user->firstName, $this->user->nationalID);
}
// Starts user session
$this->begin_session();
// $this->signUp($this->user, $this->user->lastName, $this->user->firstName, $this->user->nationalID);
}
}
示例2: addTask
public function addTask(Request $request)
{
$parseTask = new ParseObject("Task");
$parseCropQuery = new ParseQuery("Crop");
$parseCropQuery->equalTo("cropName", $request->input('crop'));
$crop = $parseCropQuery->first();
$parseQuery = new ParseQuery("Task");
$parseQuery->equalTo("cropName", $crop);
$parseQuery->equalTo("taskDesc", $request->input('taskName'));
if ($parseQuery->count() > 0) {
return redirect('/tasks');
}
$parseTask->set("cropName", $crop);
$parseTask->set("taskDesc", $request->input('taskName'));
$parseTask->set("taskDuration", $request->input('taskDuration'));
$parseTask->set("taskStart", $request->input('taskStart'));
try {
$parseTask->save();
\Session::put('message', 1);
return redirect('tasks');
} catch (ParseException $e) {
\Session::put('message', -1);
return redirect('tasks');
}
}
示例3: __construct
public function __construct($objectId = null)
{
parent::__construct("Camera", $objectId, false);
$query = new ParseQuery("Camera");
$query->equalTo("objectId", $objectId);
$this->_cam = $query->first();
}
示例4: __construct
public function __construct($objectId = null)
{
parent::__construct("AnimalV2", $objectId, false);
$query = new ParseQuery("AnimalV2");
$query->equalTo("objectId", $objectId);
$this->_animal = $query->first();
}
示例5: getById
public function getById($objectId)
{
$query = new ParseQuery($this->getClassName());
$query->equalTo('objectId', $objectId);
$results = $query->first();
return $results;
}
示例6: findBy
/**
* @param $field
* @param $value
* @param array $columns
* @param array $keyToInclude
*
* @return ParseObject
*/
public function findBy($field, $value, $columns = ['*'], $keyToInclude = [])
{
$this->query->equalTo($field, $value);
for ($i = 0; $i < count($keyToInclude); $i++) {
$this->query->includeKey($keyToInclude[$i]);
}
return $this->query->first($this->useMasterKey);
}
示例7: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
*
* @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null
* @throws \Exception
* @throws \Parse\ParseException
*/
public function retrieveByCredentials(array $credentials)
{
$username = $this->getUsernameFromCredentials($credentials);
$query = new ParseQuery('_User');
$query->equalTo('username', $username);
$user = $query->first(true);
return empty($user) ? null : $user;
}
示例8: first
/**
* 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);
}
}
示例9: enviarAtualizacao
/**
* Envia push de atualizaçao.
*
* @return Response
*/
public function enviarAtualizacao()
{
try {
ParseClient::initialize('YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0', 'zNGQwg11i4fQRhGUCZIR777A8VRWjCqe3BQeZgDI', '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o');
$session = Cache::get('sessionToken', 'default');
$usuario = ParseUser::become($session);
$texto = Input::get('texto');
$atualizacaoQuery = new ParseQuery("Atualizacao");
$atualizacaoQuery->descending("numero");
$ultimaAtualizacao = $atualizacaoQuery->first();
$novoNumero = $ultimaAtualizacao->get('numero') + 1;
$novaAtualizacao = new ParseObject("Atualizacao");
$novaAtualizacao->set('numero', $novoNumero);
$novaAtualizacao->set('usuario', $usuario);
$novaAtualizacao->set('texto', $texto);
$novaAtualizacao->save();
// $fields = array('Accept'=>'application/json',
// 'X-Parse-Application-Id' => 'YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0',
// 'X-Parse-Master-Key' => '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o');
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, 'https://api.parse.com/1/jobs/jobTeste');
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
// curl_setopt($ch, CURLOPT_HEADER, $fields);
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// // curl_setopt(CURLOPT_USERPWD, 'XXXXXX');
// $result = curl_exec($ch);
// curl_close($ch);
// $cmd='curl -X POST \
// -H \"X-Parse-Application-Id: YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0\" \
// -H \"X-Parse-Master-Key: 4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o\" \
// -H \"Content-Type: application/json\" \
// -d \"{\"plan\":\"paid\"}\" \
// https://api.parse.com/1/jobs/jobTeste';
// Log::info($cmd);
// exec($cmd,$result);
Log::info("CHEGUEI NEGAO");
// Log::info($result);
return 200;
} catch (ParseException $error) {
return $error;
}
}
示例10: firstQuery
public function firstQuery()
{
$query = new ParseQuery("Test");
try {
ParseClient::$THROW_RESPONSE = true;
$results = $query->first();
} catch (\Exception $ex) {
$msg = json_decode($ex->getMessage(), true);
return $msg ? $msg : $ex->getMessage();
}
}
示例11: testIncludeMultipleKeys
public function testIncludeMultipleKeys()
{
Helper::clearClass("Foo");
Helper::clearClass("Bar");
Helper::clearClass("Parent");
$foo = ParseObject::create('Foo');
$foo->set('rev', 'oof');
$foo->save();
$bar = ParseObject::create('Bar');
$bar->set('rev', 'rab');
$bar->save();
$parent = ParseObject::create('Parent');
$parent->set('foofoo', $foo);
$parent->set('barbar', $bar);
$parent->save();
$query = new ParseQuery('Parent');
$query->includeKey(['foofoo', 'barbar']);
$result = $query->first();
$this->assertEquals('oof', $result->get('foofoo')->get('rev'), 'Object should be fetched');
$this->assertEquals('rab', $result->get('barbar')->get('rev'), 'Object should be fetched');
}
示例12: ParseSessionStorage
require 'vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseUser;
use Parse\ParseSessionStorage;
use Parse\ParseQuery;
use Parse\ParseObject;
ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ');
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
ParseClient::setStorage(new ParseSessionStorage());
$currentUser = ParseUser::getCurrentUser();
$courseTitle = $_POST["course"];
$classNumber = $_POST["classNumber"];
$courseQuery = new ParseQuery("Course");
$courseQuery->equalTo("Title", $courseTitle);
$course = $courseQuery->first();
$classQuery = new ParseQuery("Class");
$classQuery->equalTo("Course", $course);
$classQuery->equalTo("ClassNumber", intval($classNumber));
$class = $classQuery->first();
$comment = new ParseObject("Comment");
$comment->set("User", $currentUser);
$currentUser->fetch();
$username = $currentUser->get("UserName");
$comment->set("UserName", $username);
$comment->set("Course", $course);
$comment->set("Class", $class);
$comment->set("Text", $_POST["comment"]);
$comment->save();
示例13: pageExists
private function pageExists($name)
{
$query = new ParseQuery('Pages');
$query->equalTo('name', $name);
$object = $query->first();
if (is_object($object)) {
return true;
}
return false;
}
示例14: ParseSessionStorage
<?php
require 'vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseUser;
use Parse\ParseSessionStorage;
use Parse\ParseQuery;
use Parse\ParseObject;
ParseClient::initialize('bYE5q8xvJEiV2A2mtf0fgbQR8olNMQ2wfr05WYco', 'wZ5XfUCgQBZzFfQOwhWzP14W1fHfe6aj4qS76u0h', '3e8xtmuzrlpgAHNq7ho5Pe5tL9HrQFEgtJD2YVvQ');
session_start();
$emailfriend = $_GET["friendEmail"];
ParseClient::setStorage(new ParseSessionStorage());
$currentUser = ParseUser::getCurrentUser();
$emailuser = $currentUser->getUsername();
$friendRequestQuery = new ParseQuery("Friends");
$friendRequestQuery->equalTo("email1", $emailfriend);
$friendRequestQuery->equalTo("email2", $emailuser);
$request = $friendRequestQuery->first();
$request->set("Aceite", 0);
$request->save();
$friendRequestQuery = new ParseQuery("Friends");
$friendRequestQuery->equalTo("email2", $emailfriend);
$friendRequestQuery->equalTo("email1", $emailuser);
$request = $friendRequestQuery->first();
$request->set("Aceite", 0);
$request->save();
示例15: Response
}
$response = new Response();
$response->id = $ids;
$response->name = $names;
$response->avatar = $avatars;
echo json_encode($response);
}
if ($func == 'get_user_direct') {
$query = new ParseQuery("_User");
$query->equalTo('objectId', $_POST['user']);
$users = $query->first();
$ids = array();
$names = array();
$avatars = array();
foreach ($users->get('connected') as $user) {
$query = new ParseQuery("_User");
$query->equalTo('objectId', $user);
$conn = $query->first();
array_push($ids, $conn->getObjectId());
array_push($names, $conn->get('first'));
array_push($avatars, $conn->get('avatar'));
}
$response = new Response();
$response->id = $ids;
$response->name = $names;
$response->avatar = $avatars;
echo json_encode($response);
}
?>