当前位置: 首页>>代码示例>>PHP>>正文


PHP ParseQuery::exists方法代码示例

本文整理汇总了PHP中Parse\ParseQuery::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseQuery::exists方法的具体用法?PHP ParseQuery::exists怎么用?PHP ParseQuery::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse\ParseQuery的用法示例。


在下文中一共展示了ParseQuery::exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getStolenBikes

function getStolenBikes()
{
    $query = new ParseQuery("Bikes");
    $query->exists("sessionStartTime");
    $query->limit(1000);
    $results = $query->find();
    $count = count($results);
    $listOfBikes = array();
    $stolenBikes = 0;
    for ($i = 0; $i < $count; $i++) {
        $startDate = $results[$i]->get("sessionStartTime");
        $startDate = $startDate->format('Y-m-d H:i:s');
        $startDate = strtotime($startDate);
        $currentDate = new DateTime('now');
        $currentDate = $currentDate->format('Y-m-d H:i:s');
        $currentDate = strtotime($currentDate);
        $subtractedDate = $currentDate - $startDate;
        $expiredTime = 200 * 60;
        if ($subtractedDate >= $expiredTime * 60) {
            $stolenBikes++;
            $bike = $results[$i];
            try {
                $lostBike = new ParseObject("LostBikes");
                $lostBike->set("bikeId", $bike->getObjectId());
                $user = $bike->get("currentUser");
                $user->fetch();
                $customerID = $user->get("stripeID");
                $amount = 200 * 100;
                $charge = \Stripe\Charge::create(array('customer' => $customerID, 'amount' => $amount, 'currency' => 'usd'));
                $lostBike->set("currentUser", $user);
                $lostBike->set("lastLocation", $bike->get("lastLocation"));
                $lostBike->set("condition", $bike->get("condition"));
                $lostBike->save();
                $bike->destroy();
            } catch (\Parse\ParseException $ex) {
                return 'Failed to create LostBikes object and destroy Bikes object ' . $ex->getMessage();
            } catch (\Stripe\Error\InvalidRequest $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\Authentication $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\ApiConnection $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\Base $e) {
                return $e->getMessage();
            } catch (Exception $e) {
                return $e->getMessage();
            }
        }
    }
    $rString = 0;
    if ($stolenBikes > 0) {
        $rString = "Successfully removed " . $stolenBikes . " stolen bikes.";
    }
    return $rString;
}
开发者ID:es2fq,项目名称:BaasAPI,代码行数:55,代码来源:removeExpiredBikes.php

示例2: testExistsRelation

 public function testExistsRelation()
 {
     Helper::clearClass("Item");
     $this->saveObjects(9, function ($i) {
         $obj = ParseObject::create("TestObject");
         if ($i & 1) {
             $obj->set('y', $i);
         } else {
             $item = ParseObject::create("Item");
             $item->set('e', $i);
             $obj->set('e', $item);
         }
         return $obj;
     });
     $query = new ParseQuery("TestObject");
     $query->exists('e');
     $results = $query->find();
     $this->assertEquals(5, count($results), 'Did not return correct number of objects.');
 }
开发者ID:rvdavid,项目名称:parse-php-sdk,代码行数:19,代码来源:ParseQueryTest.php

示例3: ParseQuery

<?php

require 'vendor/autoload.php';
require 'api.php';
use Parse\ParseClient;
use Parse\ParseQuery;
use Parse\ParseObject;
ParseClient::initialize('AQ2Vfb0vhbBq3N6t2Aeu4fpLaZ5Xp8HI42P1fOxr', 'yFuVB8uoineYD9d2DXredK3QF0ZH4N0IHcMx9oLf', '34h4r0BN7uE0w64iGdjFqvNqpIejoorV1Gdf82we');
$query = new ParseQuery("Subjects");
$query->exists("SchoolCode");
$results = $query->find();
foreach ($results as $el) {
    $schoolCode = $el->SchoolCode;
    $subjectCode = $el->SubjectCode;
    $url = 'https://api-gw.it.umich.edu/Curriculum/SOC/v1/Terms/2010/Schools/' . $schoolCode . '/Subjects/' . $subjectCode . '/CatalogNbrs';
    //$url = 'https://api-gw.it.umich.edu/Curriculum/SOC/v1/Terms/2010/Schools/ENG/Subjects/EECS/CatalogNbrs';
    $class = new UMapis();
    $json = $class->call_api($url);
    $data = json_decode($json);
    if ($data) {
        if ($data->getSOCCtlgNbrsResponse) {
            if (isset($data->getSOCCtlgNbrsResponse->ClassOffered)) {
                foreach ($data->getSOCCtlgNbrsResponse->ClassOffered as $class) {
                    $courseNbr = (int) $class->CatalogNumber;
                    $courseDescr = $class->CourseDescr;
                    $course = new ParseObject('Classes');
                    $course->set('SchoolCode', $schoolCode);
                    $course->set('SubjectCode', $subjectCode);
                    $course->set('CatalogNbr', $courseNbr);
                    $course->set('CatalogDescr', $courseDescr);
                    $course->save();
开发者ID:cocarson,项目名称:MLink,代码行数:31,代码来源:db_setup.php

示例4: getExpiredReservedBikes

 function getExpiredReservedBikes()
 {
     $query = new ParseQuery("Bikes");
     $query->exists("reservedTime");
     $query->limit(1000);
     $results = $query->find();
     $count = count($results);
     $listOfBikes = array();
     for ($i = 0; $i < $count; $i++) {
         $reservedDate = $results[$i]->get("reservedTime");
         $reservedDate = $reservedDate->format('Y-m-d H:i:s');
         $reservedDate = strtotime($reservedDate);
         $currentDate = new DateTime('now');
         $currentDate = $currentDate->format('Y-m-d H:i:s');
         $currentDate = strtotime($currentDate);
         $subtractedDate = $currentDate - $reservedDate;
         echo $subtractedDate;
         echo "s ";
         $expiredTime = 10;
         if ($subtractedDate >= $expiredTime * 60) {
             array_push($listOfBikes, $results[$i]->getObjectId());
         }
     }
     return $listOfBikes;
 }
开发者ID:es2fq,项目名称:BaasAPI,代码行数:25,代码来源:BaasAPI.php

示例5: ParseQuery

ParseClient::initialize($app_id, $rest_key, $master_key);
try {
    $userQuery = ParseUser::query();
    $userQuery->exists("objectId");
    // This is not efficiant but Parse lacks random access to objects
    $users = $userQuery->find();
    /*
     * The Key in $chosenObjects should be the name you want to display in the UML
     */
    $chosenObjects['_User'] = $users[0];
    /*
     * Custum class (Temperature for demo)
     * You can add as many as you want
     */
    $custumQuery = new ParseQuery("Temperature");
    $custumQuery->exists("objectId");
    // Same as line 23
    $custumObjects = $custumQuery->find();
    /*
     * Add an array of custum objects to be inclused in the UML
     */
    $chosenObjects['Temperature'] = $custumObjects;
    // We can pass an array of objects
    /*
     * Pass the array $chosenObjects to getUML method
     * @return : String (Null if error)
     */
    $UML = $schema->getUML($chosenObjects);
    if ($UML) {
        /*
         * Get the client to download the txt file
开发者ID:Jessianngeorge,项目名称:Parse-UML,代码行数:31,代码来源:index.php


注:本文中的Parse\ParseQuery::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。