本文整理汇总了PHP中Parse\ParseQuery::containedIn方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseQuery::containedIn方法的具体用法?PHP ParseQuery::containedIn怎么用?PHP ParseQuery::containedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseQuery
的用法示例。
在下文中一共展示了ParseQuery::containedIn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: containedIn
/**
* ObjectModels are replaced for their ParseObjects. It also accepts any kind
* of traversable variable.
*
* @param string $key
* @param mixed $values
*
* @return $this
*/
public function containedIn($key, $values)
{
if (!is_array($values) && !$values instanceof Traversable) {
$values = [$values];
}
foreach ($values as $k => $value) {
if ($value instanceof ObjectModel) {
$values[$k] = $value->getParseObject();
}
}
$this->parseQuery->containedIn($key, $values);
return $this;
}
示例2: showHome
public function showHome(Request $request)
{
$current_user = ParseUser::getCurrentUser();
if (!$current_user) {
return redirect()->route('login');
}
$query = ParseUser::query();
$current_user = $query->get($current_user->getObjectId());
Html\Assets::addLink(Html\Link::Css(elixir('css/default.css')));
Html\Assets::addMetaTag(Html\Meta::Tag('description', ''));
$query = new ParseQuery("ChatRoom");
$query->equalTo('members', $current_user);
try {
$chatRooms = $query->find();
$query = new ParseQuery("Messages");
$query->containedIn("chatRoom", $chatRooms);
$query->descending('createdAt');
$query->includeKey('chatRoom');
$query->includeKey('user');
$query->limit(20);
$messages = $query->find();
$data = [];
foreach ($messages as $message) {
$chatRoom = $message->get('chatRoom');
$event = $chatRoom->get('event');
$evQuery = new ParseQuery('Events');
$evQuery->includeKey('group');
$event = $evQuery->get($event->getObjectId());
$group = $event->get('group');
$relation = $message->getRelation("asset");
$aqry = $relation->getQuery();
$assets = $aqry->find();
$temp = ['group' => $group, 'event' => $event, 'chatRoom' => $chatRoom, 'message' => ['msg' => $message, 'assets' => $assets], 'user' => $message->get('user')];
$data[] = $temp;
}
} catch (ParseException $ex) {
// The object was not retrieved successfully.
// error is a ParseException with an error code and message.
echo $ex->getMessage();
}
$renderData = $this->getRenderData($request);
$renderData['user'] = $current_user;
$renderData['activeBarTab'] = "dashboard";
$renderData['data'] = $data;
return view('home', $renderData);
}
示例3: fetchAll
/**
* Fetch an array of Parse objects from the server.
*
* @param array $objects The ParseObjects to fetch
* @param bool $useMasterKey Whether to override ACLs
*
* @return array
*/
public static function fetchAll(array $objects, $useMasterKey = false)
{
$objectIds = static::toObjectIdArray($objects);
if (!count($objectIds)) {
return $objects;
}
$className = $objects[0]->getClassName();
$query = new ParseQuery($className);
$query->containedIn('objectId', $objectIds);
$query->limit(count($objectIds));
$results = $query->find($useMasterKey);
return static::updateWithFetchedResults($objects, $results);
}
示例4: dtestContainedInUserArrayQueries
public function dtestContainedInUserArrayQueries()
{
ParseTestHelper::clearClass(ParseUser::$parseClassName);
ParseTestHelper::clearClass("TestObject");
$userList = [];
for ($i = 0; $i < 4; $i++) {
$user = new ParseUser();
$user->setUsername('user_num_' . $i);
$user->setPassword('password');
$user->set('email', 'asdf_' . $i . '@example.com');
$user->signUp();
$userList[] = $user;
}
$messageList = [];
for ($i = 0; $i < 5; $i++) {
$message = ParseObject::create('TestObject');
$toUser = ($i + 1) % 4;
$fromUser = $i % 4;
$message->set('to', $userList[$toUser]);
$message->set('from', $userList[$fromUser]);
$message->save();
$messageList[] = $message;
}
$inList = [$userList[0], $userList[3], $userList[3]];
$query = new ParseQuery("TestObject");
$query->containedIn('from', $inList);
$results = $query->find();
$this->assertEquals(3, count($results));
}
示例5: testObjectIdContainedInQueries
public function testObjectIdContainedInQueries()
{
Helper::clearClass("BoxedNumber");
$objects = [];
$this->saveObjects(5, function ($i) use(&$objects) {
$boxedNumber = ParseObject::create("BoxedNumber");
$boxedNumber->set("number", $i);
$objects[] = $boxedNumber;
return $boxedNumber;
});
$query = new ParseQuery("BoxedNumber");
$query->containedIn("objectId", [$objects[2]->getObjectId(), $objects[3]->getObjectId(), $objects[0]->getObjectId(), "NONSENSE"]);
$query->ascending("number");
$results = $query->find();
$this->assertEquals(3, count($results), 'Did not return correct number of objects.');
$this->assertEquals(0, $results[0]->get("number"), 'Did not return the correct object.');
$this->assertEquals(2, $results[1]->get("number"), 'Did not return the correct object.');
$this->assertEquals(3, $results[2]->get("number"), 'Did not return the correct object.');
}
示例6: testQueriesOnRelationFields
public function testQueriesOnRelationFields()
{
$children = [];
$this->saveObjects(10, function ($i) use(&$children) {
$child = ParseObject::create('ChildObject');
$child->set('x', $i);
$children[] = $child;
return $child;
});
$parent = ParseObject::create('ParentObject');
$parent->set('x', 4);
$relation = $parent->getRelation('children');
$relation->add([$children[0], $children[1], $children[2]]);
$parent->save();
$parent2 = ParseObject::create('ParentObject');
$parent2->set('x', 3);
$relation2 = $parent2->getRelation('children');
$relation2->add([$children[4], $children[5], $children[6]]);
$parent2->save();
$query = new ParseQuery('ParentObject');
$query->containedIn('children', [$children[4], $children[9]]);
$results = $query->find();
$this->assertEquals(1, count($results));
$this->assertEquals($results[0]->getObjectId(), $parent2->getObjectId());
}
示例7: ParseQuery
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
switch ($_REQUEST['action']) {
case "login":
$user = ParseUser::logIn($_REQUEST['username'], $_REQUEST['password']);
$returnData = json_encode(array("success" => true, "data" => $user));
break;
case 'Employers':
$employers = new ParseQuery("Employers");
if (isset($_GET['objectId'])) {
$objarr = explode(",", str_replace('"', "", $_GET['objectId']));
$employers->containedIn("objectId", $objarr);
}
if (isset($_GET['agencyId'])) {
$objarr = explode(",", str_replace('"', "", $_GET['agencyId']));
$employers->containedIn("agencyId", $objarr);
}
$employers->limit(1000);
$results = $employers->find();
$returnData = json_encode(array("success" => true, "data" => $results));
break;
case 'Agency':
$agency = new ParseQuery("Agency");
$agency->limit(1000);
$agency->descending("createdAt");
$results = $agency->find();
$returnData = json_encode(array("success" => true, "data" => $results));
示例8: wtd_bus_options
function wtd_bus_options($field, $value)
{
$place = 'business_categories_options';
$parent_filters = get_option('wtd_excluded_parent_cats');
if (!empty($parent_filters)) {
$enabled_parent_cat_filters = json_decode($parent_filters);
}
$excluded_cats = get_option('wtd_excluded_cats');
?>
<div ng-controller="categoryExclusion"><?php
$query = new ParseQuery('wp_site');
$query->equalTo('token', get_option('wtd_api_token'));
$site_results = $query->find();
$site = $site_results[0];
$relation = $site->getRelation('resortRelation', 'resort');
$resorts = $relation->getQuery()->find();
$query = new ParseQuery('resortParentCategories');
$query->equalTo('deleted', false);
$query->containedIn('resortObjectId', $resorts);
$query->includeKey('resortObjectId');
$results = $query->find();
?>
<script type="text/javascript"><?php
if (empty($enabled_parent_cat_filters)) {
?>
var enabled_parent_filters = null;
var excluded_cats = null;<?php
} else {
?>
var enabled_parent_filters = JSON.parse('<?php
echo empty($parent_filters) ? '{"result":true}' : $parent_filters;
?>
');<?php
if (empty($excluded_cats)) {
?>
var excluded_cats = null;<?php
} else {
?>
var excluded_cats = JSON.parse('<?php
echo $excluded_cats;
?>
');<?php
}
}
?>
jQuery(document).ready(function(){
if(enabled_parent_filters!= null && enabled_parent_filters!= undefined ){
for(var i = 0; i < enabled_parent_filters.length; i++){
var parent_id = enabled_parent_filters[i];
Parse.Cloud.run('get_subcategory_list_v2', {
parent_id: parent_id,
token: token
}, {
success: function(result){
showSubcategoryList(parent_id, result);
},
error: function(error){
console.log(error);
}
});
}
}
});
</script>
<div data-place="<?php
echo $place;
?>
"><?php
for ($i = 0; $i < count($results); $i++) {
$cat = $results[$i];
$cat_id = $cat->getObjectId();
$cat_enable = '';
$cat_disable = 'selected';
if (!empty($enabled_parent_cat_filters)) {
if (in_array($cat->getObjectId(), $enabled_parent_cat_filters)) {
$cat_enable = 'selected';
$cat_disable = '';
}
}
?>
<div id="<?php
echo $place;
?>
_parent_<?php
echo $cat_id;
?>
">
<fieldset class="redux-field-container redux-field redux-container-switch" data-id="category-<?php
echo $cat->getObjectId();
?>
" data-type="switch">
<div class="switch-options">
<label id="<?php
echo $cat_id;
?>
_filter_enabled" class="cb-enable <?php
echo $cat_enable;
?>
" ng-click="getSubcategories('<?php
//.........这里部分代码省略.........
示例9: matrix
private function matrix()
{
global $post;
$res_id = get_post_meta($post->ID, 'res_id', true);
$query = new ParseQuery("resort");
try {
$resort = $query->get($res_id);
} catch (ParseException $ex) {
error_log($ex->getMessage());
}
$query = new ParseQuery('resortParentCategories');
$query->equalTo('deleted', false);
$query->containedIn('cat_class', ['A', 'R']);
$query->equalTo('resortObjectId', $resort);
$query->greaterThan("activityCnt", 0);
$query->ascending('name');
try {
$parent_cats = $query->find();
} catch (ParseException $ex) {
error_log($ex->getMessage());
}
?>
<link rel="stylesheet" href="<?php
echo WTD_PLUGIN_URL . "assets/css/styles/wtd_menu.css?wtd_version=" . WTD_VERSION;
?>
" media="screen"/>
<link rel="stylesheet" href="<?php
echo WTD_PLUGIN_URL . "assets/css/styles/masonry.css?wtd_version=" . WTD_VERSION;
?>
" media="screen"/>
<div id="wtd_parent_menu" class="grid">
<div class="masonry-column-width"></div><?php
for ($i = 0; $i < count($parent_cats); $i++) {
$parent_cat = $parent_cats[$i];
$url = site_url() . '/' . $post->post_name . '/whattodo/' . strtolower($parent_cat->get('name')) . '/' . $parent_cat->getObjectId() . '/';
//if($image):
?>
<div class="masonry-entry">
<div class="masonry-thumbnail">
<a href="<?php
echo $url;
?>
" title="<?php
echo $parent_cat->get('name');
?>
">
<img src="<?php
echo WTD_IMG_BASE . $parent_cat->get('cat_img');
?>
" class="masonry-thumb"/>
</a>
</div>
<div class="masonry-details">
<h5>
<a href="<?php
echo $url;
?>
" title="<?php
echo $parent_cat->get('name');
?>
">
<span class="masonry-post-title"><?php
echo $parent_cat->get('name');
?>
</span>
</a>
</h5>
</div>
</div><?php
//endif;
}
?>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
var grid = jQuery('.grid').masonry({
// options
itemSelector: '.masonry-entry',
columnWidth: '.masonry-column-width',
percentPosition: true,
gutter: 10
});
// layout Masonry after each image loads
grid.imagesLoaded().progress(function(){
grid.masonry('layout');
});
});
</script><?php
wtd_copyright();
}