Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function process(array $settings = [])
 {
     $this->processOrders($settings);
     $this->processFilters($settings);
     $this->source->limit($settings['limit']);
     $this->source->skip(($settings['page'] - 1) * $settings['limit']);
     // run queries
     $gridData = new Grid\Data($this->source->find());
     // get all records to set grid total
     // @todo: cache result of total query for few minutes
     $this->source = new ParseQuery($this->collectionName);
     $this->processOrders($settings);
     $this->processFilters($settings);
     $gridData->setTotal(sizeof($this->source->limit(1000)->find()));
     return $gridData;
 }
 /**
  * Lists all ProjectsAdmin entities.
  *
  * @Route("/index/{page}", name="admin_projects", defaults={ "page" = 1 })
  * @Method("GET")
  * @Template()
  */
 public function indexAction($page)
 {
     $query = new ParseQuery('Project');
     $query->ascending("label");
     $query->limit(12);
     $query->skip(12 * ($page - 1));
     $entities = $query->find();
     return array('entities' => $entities, 'hits' => ceil($query->count() / 12), 'page' => $page, 'csrf' => $this->get('form.csrf_provider'));
 }
Exemplo n.º 3
0
 public function testEachFailsWithSkip()
 {
     $total = 50;
     $count = 25;
     $this->saveObjects($total, function ($i) {
         $obj = new ParseObject("Object");
         $obj->set("x", $i + 1);
         return $obj;
     });
     $query = new ParseQuery("Object");
     $query->lessThanOrEqualTo("x", $count);
     $query->skip(5);
     $this->setExpectedException('\\Exception', 'skip');
     $query->each(function ($obj) {
     });
 }
Exemplo n.º 4
0
 $originated = originated($user->getObjectId());
 $query = new ParseQuery("_User");
 $query->equalTo("objectId", $user->getObjectId());
 $user = $query->first();
 $query = new ParseQuery("NiceThing");
 $query->includeKey("refered_user");
 $query->descending("createdAt");
 $query->limit(3);
 $lastthreethings = $query->find();
 $new = 0;
 $inbox = 0;
 $query = new ParseQuery("_Session");
 $query->equalTo("user", $user);
 $query->includeKey("user");
 $query->descending("createdAt");
 $query->skip(1);
 $query->limit(1);
 $new = $query->find(true);
 if ($_SESSION['notification']) {
     $query = new ParseQuery("ChatLogs");
     $query->greaterThan('createdAt', date_format($new[0]->getCreatedAt(), 'Y-m-d\\TH:i:s.u\\Z'));
     $inbox = count($query->find());
     $query = new ParseQuery("NiceThing");
     $query->greaterThan('createdAt', $new[0]->getCreatedAt());
     $query->equalTo("refered_user", $user);
     $new = count($query->find());
     $_SESSION['notification'] = false;
 } else {
     $query = new ParseQuery("ChatLogs");
     $query->equalTo('reciever', $user->getObjectId());
     $query->greaterThan('createdAt', $_SESSION['last_date']);
Exemplo n.º 5
0
 public function first($className, $equalToArray = array(), $ascending = null, $descending = null, $skip = null, $includeArray = array())
 {
     $query = new ParseQuery($className);
     if ($equalToArray) {
         foreach ($equalToArray as $key => $value) {
             $query->equalTo($key, $value);
         }
     }
     if ($ascending) {
         $query->ascending($ascending);
     }
     if ($descending) {
         $query->descending($descending);
     }
     if ($skip) {
         $query->skip($skip);
     }
     if ($includeArray) {
         foreach ($includeArray as $include) {
             $query->includeKey($include);
         }
     }
     return $query->first();
 }
Exemplo n.º 6
0
<?php

require '../init.php';
use Parse\ParseQuery;
// Function to check if the request is an AJAX request
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
if (is_ajax()) {
    $query = new ParseQuery("Episode");
    $query->descending("epId");
    $query->skip(FIRST_SHOWN_LIMIT);
    $heldeeps = $query->find();
    $count = count($heldeeps);
    $contents = [];
    for ($i = 0; $i < count($heldeeps); $i++) {
        $heldeep = $heldeeps[$i];
        $query = new ParseQuery("Track");
        $query->equalTo("episode", $heldeep);
        $tracks = $query->find();
        $content = "";
        for ($j = 0; $j < count($tracks); $j++) {
            $track = $tracks[$j];
            if ($special = $track->get("type")) {
                $content .= "<h4>{$special}</h4>";
            }
            $content .= "<li" . ($special ? " class='special'" : "") . ">" . $track->get("title");
            $content .= "<a target='_blank' href='https://soundcloud.com/search?q=" . urlencode($track->get("title")) . "'><i class='fa fa-search'></i></a>";
            $content .= "</li>";
        }