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


PHP ParseObject::saveAll方法代码示例

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


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

示例1: saveObjects

 /**
  * This function used as a helper function in test functions to save objects.
  *
  * @param int      $numberOfObjects Number of objects you want to save.
  * @param callable $callback        Function which takes int as a parameter.
  *                                  and should return ParseObject.
  */
 public function saveObjects($numberOfObjects, $callback)
 {
     $allObjects = [];
     for ($i = 0; $i < $numberOfObjects; $i++) {
         $allObjects[] = $callback($i);
     }
     ParseObject::saveAll($allObjects);
 }
开发者ID:rvdavid,项目名称:parse-php-sdk,代码行数:15,代码来源:ParseQueryTest.php

示例2: _addTestObjects

 private function _addTestObjects($numberOfObjects = 5)
 {
     $objects = [];
     for ($i = 0; $i < $numberOfObjects; $i++) {
         $object = new ParseObject($this->testParseClassName);
         $object->set('String', 'String' . $i);
         $objects[] = $object;
     }
     ParseObject::saveAll($objects);
 }
开发者ID:funkardotnu,项目名称:cacheableparsequery,代码行数:10,代码来源:CacheableParseQueryTest.php

示例3: createEden

 public function createEden()
 {
     $eden = [];
     $eden['adam'] = $this->createUser('adam');
     $eden['eve'] = $this->createUser('eve');
     $eden['snake'] = $this->createUser('snake');
     $eden['adam']->signUp();
     $eden['eve']->signUp();
     $eden['snake']->signUp();
     $eden['humans'] = ParseRole::createRole('humans', $this->aclPublic());
     $eden['humans']->getUsers()->add($eden['adam']);
     $eden['humans']->getUsers()->add($eden['eve']);
     $eden['creatures'] = ParseRole::createRole('creatures', $this->aclPublic());
     $eden['creatures']->getUsers()->add($eden['snake']);
     ParseObject::saveAll([$eden['humans'], $eden['creatures']]);
     $eden['edenkin'] = ParseRole::createRole('edenkin', $this->aclPublic());
     $eden['edenkin']->getRoles()->add($eden['humans']);
     $eden['edenkin']->getRoles()->add($eden['creatures']);
     $eden['edenkin']->save();
     $eden['apple'] = ParseObject::create('Things');
     $eden['apple']->set('name', 'apple');
     $eden['apple']->set('ACL', $this->aclPrivateTo($eden['humans']));
     $eden['garden'] = ParseObject::create('Things');
     $eden['garden']->set('name', 'garden');
     $eden['garden']->set('ACL', $this->aclPrivateTo($eden['edenkin']));
     ParseObject::saveAll([$eden['apple'], $eden['garden']]);
     return $eden;
 }
开发者ID:khangaikh,项目名称:golocal,代码行数:28,代码来源:ParseRoleTest.php

示例4: testCannotSaveAllWithOtherUser

 public function testCannotSaveAllWithOtherUser()
 {
     $user = new ParseUser();
     $user->setUsername("asdf");
     $user->setPassword("zxcv");
     $user->signUp();
     $otherUser = new ParseUser();
     $otherUser->setUsername("hacker");
     $otherUser->setPassword("password");
     $otherUser->signUp();
     $this->assertEquals(ParseUser::getCurrentUser(), $otherUser);
     $obj = ParseObject::create("TestObject");
     $obj->set('user', $otherUser);
     $obj->save();
     $item1 = ParseObject::create("TestObject");
     $item1->set('num', 0);
     $item1->save();
     $item1->set('num', 1);
     $item2 = ParseObject::create("TestObject");
     $item2->set('num', 2);
     $user->setUsername('changed');
     $this->setExpectedException('Parse\\ParseAggregateException', 'Errors during batch save.');
     ParseObject::saveAll([$item1, $item2, $user]);
 }
开发者ID:nidalb,项目名称:baas,代码行数:24,代码来源:ParseUserTest.php

示例5: testFetchAll

 public function testFetchAll()
 {
     $obj1 = ParseObject::create('TestObject');
     $obj2 = ParseObject::create('TestObject');
     $obj3 = ParseObject::create('TestObject');
     $obj1->set('foo', 'bar');
     $obj2->set('foo', 'bar');
     $obj3->set('foo', 'bar');
     ParseObject::saveAll([$obj1, $obj2, $obj3]);
     $newObj1 = ParseObject::create('TestObject', $obj1->getObjectId());
     $newObj2 = ParseObject::create('TestObject', $obj2->getObjectId());
     $newObj3 = ParseObject::create('TestObject', $obj3->getObjectId());
     $results = ParseObject::fetchAll([$newObj1, $newObj2, $newObj3]);
     $this->assertEquals(3, count($results));
     $this->assertEquals('bar', $results[0]->get('foo'));
     $this->assertEquals('bar', $results[1]->get('foo'));
     $this->assertEquals('bar', $results[2]->get('foo'));
 }
开发者ID:aglo35,项目名称:vr_beta,代码行数:18,代码来源:ParseObjectTest.php

示例6: testACLSaveAllWithPermissions

 public function testACLSaveAllWithPermissions()
 {
     $alice = new ParseUser();
     $alice->setUsername('alice');
     $alice->setPassword('wonderland');
     $alice->signUp();
     $acl = ParseACL::createACLWithUser($alice);
     $object1 = ParseObject::create('Object');
     $object1->setACL($acl);
     $object1->save();
     $object2 = ParseObject::create('Object');
     $object2->setACL($acl);
     $object2->save();
     $this->assertTrue($object1->getACL()->getUserReadAccess($alice));
     $this->assertTrue($object1->getACL()->getUserWriteAccess($alice));
     $this->assertFalse($object1->getACL()->getPublicReadAccess());
     $this->assertFalse($object1->getACL()->getPublicWriteAccess());
     $this->assertTrue($object2->getACL()->getUserReadAccess($alice));
     $this->assertTrue($object2->getACL()->getUserWriteAccess($alice));
     $this->assertFalse($object2->getACL()->getPublicReadAccess());
     $this->assertFalse($object2->getACL()->getPublicWriteAccess());
     $object1->set('foo', 'bar');
     $object2->set('foo', 'bar');
     ParseObject::saveAll([$object1, $object2]);
     $query = new ParseQuery('Object');
     $query->equalTo('foo', 'bar');
     $this->assertEquals(2, count($query->find()));
 }
开发者ID:rvdavid,项目名称:parse-php-sdk,代码行数:28,代码来源:ParseACLTest.php

示例7: testBatchSaveExceptions

 public function testBatchSaveExceptions()
 {
     $obj1 = ParseObject::create("TestObject");
     $obj2 = ParseObject::create("TestObject");
     $obj1->set("fos^^co", "hi");
     $obj2->set("fo^^mo", "hi");
     try {
         ParseObject::saveAll([$obj1, $obj2]);
         $this->fail("Save should have failed.");
     } catch (\Parse\ParseAggregateException $ex) {
         $errors = $ex->getErrors();
         $this->assertContains("invalid field name", $errors[0]['error']);
         $this->assertContains("invalid field name", $errors[1]['error']);
     }
 }
开发者ID:GaurabAryal,项目名称:Fungeons-Web,代码行数:15,代码来源:ParseObjectTest.php


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