public function testComplexQueries() { Helper::clearClass("Child"); Helper::clearClass("Parent"); $this->saveObjects(10, function ($i) { $child = new ParseObject("Child"); $child->set("x", $i); $parent = new ParseObject("Parent"); $parent->set("y", $i); $parent->set("child", $child); return $parent; }); $subQuery = new ParseQuery("Child"); $subQuery->equalTo("x", 4); $query1 = new ParseQuery("Parent"); $query1->matchesQuery("child", $subQuery); $query2 = new ParseQuery("Parent"); $query2->lessThan("y", 2); $orQuery = ParseQuery::orQueries([$query1, $query2]); $results = $orQuery->find(); $this->assertEquals(3, count($results), 'Did not return correct number of objects.'); }
public function getAttractions() { $city = new ParseQuery("Cities"); $city->equalTo("city_name", "NewYork"); $query = new ParseQuery("attractions"); $query->matchesQuery("city_attractions", $city); $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { $attractions = $query->find(); return view('expertTemplate.displayAttractions')->with('attractions', $attractions)->with('currentUser', $currentUser); } else { } }
private function results() { global $wp_query, $post, $wtd_plugin, $wtd_connector; $res_id = get_post_meta($post->ID, 'res_id', true); $query = new ParseQuery("resort"); try { $resort = $query->get($res_id); // The object was retrieved successfully. } catch (ParseException $ex) { error_log($ex->getMessage()); } $cat_id = get_query_var('wtds'); if (empty($cat_id) && isset($_GET['wtds'])) { $cat_id = $_GET['wtds']; } // get parent category $query = new ParseQuery('resortParentCategories'); $query->equalTo('cat_class', 'D'); $query->equalTo('resortObjectId', $resort); $parent_cat = $query->find(); $parent_cat = $parent_cat[0]; // get category if its set if (!empty($cat_id)) { $query = new ParseQuery('resortCategory'); try { $cat = $query->get($cat_id); } catch (\Parse\ParseException $ex) { var_dump($ex); } } // parent restriction query $parent_cat_query = new ParseQuery('resortParentCategories'); $parent_cat_query->equalTo('objectId', $parent_cat->getObjectId()); // subcategory query $query = new ParseQuery('resortCategory'); $query->matchesQuery('parentResCatObjectId', $parent_cat_query); $query->greaterThan('diningCnt', 0); $query->ascending('name'); $categories = $query->find(); ?> <link rel="stylesheet" href="<?php echo WTD_PLUGIN_URL . 'assets/css/wtd_activities_page.css?wtd_version=' . WTD_VERSION; ?> " media="screen"/> <div ng-app="diningApp" ng-controller="diningCtrl"> <div layout="row" layout-sm="column" layout-padding><?php if ($wtd_plugin['dining_page_type'] == 3) { ?> <ul layout="column"><?php for ($i = 0; $i < count($categories); $i++) { $category = $categories[$i]; $category_url_name = strtolower($parent_cat->get('name')); $category_url_name = str_replace(' ', '-', $category_url_name); $category_url_name = str_replace('/', '-', $category_url_name); $subcategory_url_name = strtolower($category->get('name')); $subcategory_url_name = str_replace(' ', '-', $subcategory_url_name); $subcategory_url_name = str_replace(',', '', $subcategory_url_name); $subcategory_url_name = str_replace('/', '-', $subcategory_url_name); $url = site_url() . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/' . $subcategory_url_name . '/' . $category->getObjectId() . '/'; ?> <li class="wtd_subcategory_menu_item <?php echo $category->getObjectId() == $wp_query->query['wtds'] ? 'active' : ''; ?> "> <a href="<?php echo $url; ?> "><?php echo $category->get('name'); ?> </a> </li><?php } ?> </ul><?php } if ($wtd_plugin['dining_page_type'] == 2) { $column_size = 100; } else { $column_size = 75; } ?> <div layout="row" layout-align="center start" ng-hide="progress == false" layout-padding flex="100"> <md-progress-circular class="md-primary" md-mode="indeterminate"></md-progress-circular> </div> <div layout="column" flex="<?php echo $column_size; ?> " flex-sm="100" ng-hide="progress == true"> <div layout="row" style="margin-bottom: 5px;"> <a id="parent_<?php echo $post->ID; ?> _header" href="<?php echo get_post_permalink($post->ID); ?> " class="wtd_pull_left"><?php echo $post->post_title; ?> </a><?php if (!empty($parent_cat_id)) { $category_url_name = strtolower($parent_cat->get('name')); $category_url_name = str_replace(' ', '-', $category_url_name); $url = site_url() . '/' . $wtd_plugin['url_prefix'] . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/'; ?> <span class="wtd_bread_separator">></span> <a id="parent_<?php echo $parent_cat->getObjectId(); ?> _header" class="wtd_pull_left" href="<?php echo $url; ?> "><?php echo $parent_cat->get('name'); ?> </a><?php } if ($wtd_plugin['dining_page_type'] == 2) { ?> <span class="wtd_bread_separator">></span> <select class="wtd_subcategory_navigator"> <option>Select Subcategory</option><?php for ($i = 0; $i < count($categories); $i++) { $category = $categories[$i]; $category_url_name = strtolower($parent_cat->get('name')); $category_url_name = str_replace(' ', '-', $category_url_name); $category_url_name = str_replace('/', '-', $category_url_name); $subcategory_url_name = strtolower($category->get('name')); $subcategory_url_name = str_replace(' ', '-', $subcategory_url_name); $subcategory_url_name = str_replace(',', '', $subcategory_url_name); $subcategory_url_name = str_replace('/', '-', $subcategory_url_name); $url = site_url() . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/' . $subcategory_url_name . '/' . $category->getObjectId() . '/'; $selected = ''; if ($cat_id == $category->getObjectId()) { $selected = ' selected="selected"'; } echo '<option value="' . $url . '" ' . $selected . '>' . $category->get('name') . '</option>'; } ?> </select><?php } elseif (!empty($cat_id)) { ?> <span class="wtd_bread_separator">></span> <span class="wtd_current_cat"><?php echo $cat->name; ?> </span><?php } ?> </div> <script> jQuery('.wtd_subcategory_navigator').change(function(){ var val = jQuery('.wtd_subcategory_navigator option:selected').val(); if(val) window.location = val; }); </script> <div layout="row" layout-align="center center" ng-hide="progress == false" layout-padding> <md-progress-circular class="md-primary" md-mode="indeterminate"></md-progress-circular> </div> <div id="wtd_listing_sc_container" layout="column" layout-align="start start"></div> </div> </div> </div><?php $wtd_base_request = $wtd_connector->get_base_request(); $wtd_base_request['resorts'] = array($res_id); $wtd_base_request['page'] = 1; $subcat_id = ""; if (!empty($cat)) { $subcat_id = $cat->getObjectId(); } if (!empty($subcat_id)) { $wtd_base_request['category_id'] = $subcat_id; } ?> <script src="//www.parsecdn.com/js/parse-1.3.5.min.js"></script> <script src="<?php echo WTD_PLUGIN_URL; ?> /assets/js/parse_init.js"></script> <script> var wtd_categories = <?php echo json_encode($this->wtd_categories); ?> ; var wtd_base_request = <?php echo json_encode($wtd_base_request); ?> ; var cat_id = '<?php echo $cat_id; ?> '; var subcat_id = '<?php echo $subcat_id; ?> '; var wtd_parse_page = 1; var cur_category = '<?php echo $cat_id; ?> '; </script> <script src="<?php echo WTD_PLUGIN_URL; ?> /assets/js/pages/dining.js"></script><?php wtd_copyright(); }
public function adminCampaignQuery() { $user = ParseUser::getCurrentUser(); $outletCheck = $user->get("company"); $companyQuery = new ParseQuery("Companies"); $companyQuery->equalTo("owner", $user); $outletQuery = new ParseQuery("Outlets"); $outletQuery->matchesQuery("company", $companyQuery); $campaign_info = []; $query = new ParseQuery("OutletOffers"); $secResult = $query->matchesQuery("outlet", $outletQuery)->includeKey("outlet")->find(); for ($i = 0; $i < count($secResult); $i++) { $object = $secResult[$i]; $venueCheck = $object->get("outlet"); $venue = $venueCheck->get("outletName"); $campaign_info[] = ['offerTitle' => $object->get("offerTitle"), 'dateCreated' => $object->getCreatedAt(), 'offerId' => $object->getObjectId(), 'offerStatus' => $object->get("offerStatus"), 'startDate' => $object->get("startDate"), 'expiryDate' => $object->get("expiryDate"), 'venue' => $venue]; } return $campaign_info; }
/** * Allow to pass instances of either Query or ParseQuery. * * @param string $key * @param Query|ParseQuery $query * * @return $this */ public function matchesQuery($key, $query) { $this->parseQuery->matchesQuery($key, $this->parseQueryFromQuery($query)); return $this; }