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


PHP Facade::trash方法代码示例

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


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

示例1: testRebuilder

 /**
  * Test SQLite table rebuilding.
  *
  * @return void
  */
 public function testRebuilder()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->xownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->xownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->xownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->xownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     $book->added = 2;
     R::store($book);
     $book->added = 'added';
     R::store($book);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:35,代码来源:Rebuild.php

示例2: testTrash

 /**
  * Tests the handling of trashed beans in frozen mode.
  * Are the lists unset etc?
  *
  * @return void
  */
 public function testTrash()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->xownPageList[] = R::dispense('page');
     $book->sharedTagList[] = R::dispense('tag');
     R::store($book);
     $book = $book->fresh();
     R::freeze(TRUE);
     $book->xownPageList = array();
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 0);
     $book->xownPageList[] = R::dispense('page');
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 1);
     $book->xownPageList;
     $book->sharedTagList;
     R::trash($book);
     asrt(R::count('book'), 0);
     asrt(R::count('page'), 0);
     asrt(R::count('tag'), 1);
     asrt(R::count('book_tag'), 0);
     R::freeze(FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:32,代码来源:Frozen.php

示例3: testKWConflicts

 /**
  * Test whether we can use foreign keys with keywords.
  *
  * @return void
  */
 public function testKWConflicts()
 {
     R::nuke();
     $metrics = R::dispense('metrics');
     $constraint = R::dispense('constraint');
     $constraint->xownMetrics[] = $metrics;
     R::store($constraint);
     asrt(1, R::count('metrics'));
     R::trash($constraint);
     asrt(0, R::count('metrics'));
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:16,代码来源:Foreignkeys.php

示例4: testIssue90

 /**
  * Test for issue90.
  * Checking 'own' relationship, makes it impossible to trash a bean.
  *
  * @return void
  */
 public function testIssue90()
 {
     $s = R::dispense('box');
     $s->name = 'a';
     $f = R::dispense('bottle');
     $s->ownBottle[] = $f;
     R::store($s);
     $s2 = R::dispense('box');
     $s2->name = 'a';
     R::store($s2);
     R::trash($s2);
     pass();
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:19,代码来源:Issue90.php

示例5: create

 public function create(Request $request, $model)
 {
     $model_name = $model;
     $record = R::dispense($model_name);
     $id = R::store($record);
     $record = R::load($model, $id);
     $columns = $record->export();
     R::trash($record);
     $uri = $request->path();
     echo "<pre>\n";
     echo "Create Uri: {$uri}\n" . "Model: {$model}\n";
     var_dump($columns);
     echo "</pre>";
 }
开发者ID:ruslan2k,项目名称:web-password,代码行数:14,代码来源:TestController.php

示例6: deletesystemlogs

 /**
  *
  * @param int $itemID
  * @return int
  */
 public function deletesystemlogs($itemID, $userid = NULL)
 {
     try {
         $rs = R::load($this->tbname, $itemID);
         if ($rs->id) {
             $row = R::trash($rs);
             return $itemID;
         } else {
             throw new Exception('No Data for Delete');
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:limweb,项目名称:webappservice,代码行数:19,代码来源:SystemlogsService.php

示例7: testExportIssue

 /**
  * In the past it was not possible to export beans
  * like 'feed' (Model_Feed).
  *
  * @return void
  */
 public function testExportIssue()
 {
     R::nuke();
     $feed = R::dispense('feed');
     $feed->post = array('first', 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = R::load('feed', $feed->id);
     $feed->post[] = 'third';
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second","third"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     asrt($feed->post[2], 'third');
     //now the catch: can we use export?
     //PHP Fatal error:  Call to a member function export() on a non-object
     $feeds = R::exportAll(R::find('feed'));
     asrt(is_array($feeds), TRUE);
     $feed = reset($feeds);
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
     //can we also dup()?
     $feedOne = R::findOne('feed');
     R::store(R::dup($feedOne));
     asrt(R::count('feed'), 2);
     //can we delete?
     R::trash($feedOne);
     asrt(R::count('feed'), 1);
     $feedTwo = R::findOne('feed');
     $feed = $feedTwo->export();
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:52,代码来源:Issue408.php

示例8: testKeywords

 /**
  * Test if RedBeanPHP can properly handle keywords.
  * 
  * @return void
  */
 public function testKeywords()
 {
     $keywords = array('anokeyword', 'znokeyword', 'group', 'drop', 'inner', 'join', 'select', 'table', 'int', 'cascade', 'float', 'call', 'in', 'status', 'order', 'limit', 'having', 'else', 'if', 'while', 'distinct', 'like');
     foreach ($keywords as $k) {
         R::nuke();
         $bean = R::dispense($k);
         $bean->{$k} = $k;
         $id = R::store($bean);
         $bean = R::load($k, $id);
         $bean2 = R::dispense('other');
         $bean2->name = $k;
         $bean->bean = $bean2;
         $bean->ownBean[] = $bean2;
         $bean->sharedBean[] = $bean2;
         $id = R::store($bean);
         R::trash($bean);
         pass();
     }
 }
开发者ID:skullyframework,项目名称:skully,代码行数:24,代码来源:Keywords.php

示例9: testBoxing

 /**
  * Test boxing beans.
  *
  * @return void
  */
 public function testBoxing()
 {
     R::nuke();
     $bean = R::dispense('boxedbean')->box();
     R::trash($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->sharedBoxbean = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->ownBoxedbean = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->other = R::dispense('boxedbean')->box();
     R::store($bean);
     pass();
     $bean = R::dispense('boxedbean');
     $bean->title = 'MyBean';
     $box = $bean->box();
     asrt($box instanceof \Model_Boxedbean, TRUE);
     R::store($box);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:29,代码来源:Boxing.php

示例10: testBasicOperations

 /**
  * Test basic CRUD operations.
  */
 public function testBasicOperations()
 {
     //Can we dispense a naughty bean? (with underscore)
     $author = R::xdispense(AUTHOR);
     asrt($author instanceof OODBBean, TRUE);
     asrt($author->getMeta('type'), AUTHOR);
     $author->name = 'Mr. Quill';
     $book = R::xdispense(BOOK);
     asrt($book instanceof OODBBean, TRUE);
     asrt($book->getMeta('type'), BOOK);
     $book->title = 'Good Stories';
     $friend = R::xdispense(FRIEND);
     $friend->name = 'Muse';
     asrt($friend instanceof OODBBean, TRUE);
     asrt($friend->getMeta('type'), FRIEND);
     $publisher = R::xdispense(PUBLISHER);
     $publisher->name = 'Good Books';
     asrt($publisher instanceof OODBBean, TRUE);
     asrt($publisher->getMeta('type'), PUBLISHER);
     asrt(is_array($author->{BOOKLIST}), TRUE);
     //add books to the book list using the constant
     $author->{BOOKLIST}[] = $book;
     asrt(count($author->{BOOKLIST}), 1);
     //can we also add friends? (N-M)
     $author->{FRIENDLIST}[] = $friend;
     $author->{PUBLISHER} = $publisher;
     $id = R::store($author);
     asrt($id > 0, TRUE);
     $author = $author->fresh();
     //Can we add another friend after reload?
     $author->{FRIENDLIST}[] = R::xdispense(FRIEND)->setAttr('name', 'buddy');
     R::store($author);
     $author = $author->fresh();
     //Now check the contents of the bean, its lists (books,friends) and parent (publisher)
     asrt($author->name, 'Mr. Quill');
     asrt(count($author->{BOOKLIST}), 1);
     $firstBook = reset($author->{BOOKLIST});
     asrt($firstBook->title, 'Good Stories');
     asrt(count($author->{FRIENDLIST}), 2);
     $firstFriend = reset($author->{FRIENDLIST});
     $parent = $author->{PUBLISHER};
     asrt($parent instanceof OODBBean, TRUE);
     $tables = R::inspect();
     //have all tables been prefixed?
     foreach ($tables as $table) {
         asrt(strpos($table, 'tbl_'), 0);
     }
     //Can we make an export?
     $export = R::exportAll(R::findOne(AUTHOR), TRUE);
     $export = reset($export);
     asrt(isset($export[PUBLISHER]), TRUE);
     asrt(isset($export[BOOKLIST]), TRUE);
     asrt(isset($export[FRIENDLIST]), TRUE);
     asrt(isset($export['ownBook']), FALSE);
     asrt(isset($export['sharedFriend']), FALSE);
     asrt(isset($export['publisher']), FALSE);
     //Can we duplicate?
     $copy = R::dup($author);
     $copy->name = 'Mr. Clone';
     R::store($copy);
     $copy = $copy->fresh();
     asrt($copy->name, 'Mr. Clone');
     asrt(count($copy->{BOOKLIST}), 1);
     $firstBook = reset($copy->{BOOKLIST});
     asrt($firstBook->title, 'Good Stories');
     asrt(count($copy->{FRIENDLIST}), 2);
     $firstFriend = reset($copy->{FRIENDLIST});
     $parent = $copy->{PUBLISHER};
     asrt($parent instanceof OODBBean, TRUE);
     //Can we count?
     asrt(R::count(AUTHOR), 2);
     $copy = $copy->fresh();
     asrt($copy->countOwn(BOOK), 1);
     asrt($copy->countShared(FRIEND), 2);
     //Can we delete?
     R::trash($author);
     asrt(R::count(AUTHOR), 1);
     //Can we nuke?
     R::nuke();
     asrt(R::count(AUTHOR), 0);
     asrt(count(R::inspect()), 0);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:85,代码来源:Prefixes.php

示例11: destroy

 /**
  * Destroy
  */
 public function destroy(Request $request, $id)
 {
     $item = R::load('item', $id);
     R::trash($item);
 }
开发者ID:ruslan2k,项目名称:web-password,代码行数:8,代码来源:ItemController.php

示例12: testENUM

 /**
  * Test ENUM functionality offered by Label Maker.
  *
  * @return void
  */
 public function testENUM()
 {
     testpack('test ENUM');
     $coffee = R::dispense('coffee');
     $coffee->taste = R::enum('flavour:mocca');
     //did we create an enum?
     asrt(implode('', R::gatherLabels(R::enum('flavour'))), 'MOCCA');
     R::store($coffee);
     $coffee = $coffee->fresh();
     //test enum identity check - with alias
     asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:mocca')), TRUE);
     asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:banana')), FALSE);
     //now we have two flavours
     asrt(R::count('flavour'), 2);
     asrt(implode(',', R::gatherLabels(R::enum('flavour'))), 'BANANA,MOCCA');
     $coffee->flavour = R::enum('flavour:mocca');
     R::store($coffee);
     //same results, can we have multiple flavours?
     asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:mocca')), TRUE);
     asrt($coffee->fetchAs('flavour')->taste->equals(R::enum('flavour:banana')), FALSE);
     asrt($coffee->flavour->equals(R::enum('flavour:mocca')), TRUE);
     //no additional mocca enum...
     asrt(R::count('flavour'), 2);
     $drink = R::dispense('drink');
     $drink->flavour = R::enum('flavour:choco');
     R::store($drink);
     //now we have three!
     asrt(R::count('flavour'), 3);
     $drink = R::load('drink', $drink->id);
     asrt($drink->flavour->equals(R::enum('flavour:mint')), FALSE);
     asrt($drink->flavour->equals(R::enum('flavour:choco')), TRUE);
     asrt(R::count('flavour'), 4);
     //trash should not affect flavour!
     R::trash($drink);
     asrt(R::count('flavour'), 4);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:41,代码来源:Misc.php

示例13: testDependency4

 /**
  * Tests dependencies (variation).
  *
  * @return void
  */
 public function testDependency4()
 {
     R::nuke();
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:23,代码来源:Foreignkeys.php

示例14: testCommonUsageFacade

 /**
  * Test common Facade usage scenarios.
  *
  * @return void
  */
 public function testCommonUsageFacade()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new AssociationManager($toolbox);
     asrt(R::getRedBean() instanceof OODB, TRUE);
     asrt(R::getToolBox() instanceof ToolBox, TRUE);
     asrt(R::getDatabaseAdapter() instanceof Adapter, TRUE);
     asrt(R::getWriter() instanceof QueryWriter, TRUE);
     $book = R::dispense("book");
     asrt($book instanceof OODBBean, TRUE);
     $book->title = "a nice book";
     $id = R::store($book);
     asrt($id > 0, TRUE);
     $book = R::load("book", (int) $id);
     asrt($book->title, "a nice book");
     asrt(R::load('book', 999)->title, NULL);
     R::freeze(TRUE);
     try {
         R::load('bookies', 999);
         fail();
     } catch (\Exception $e) {
         pass();
     }
     R::freeze(FALSE);
     $author = R::dispense("author");
     $author->name = "me";
     R::store($author);
     $book9 = R::dispense("book");
     $author9 = R::dispense("author");
     $author9->name = "mr Nine";
     $a9 = R::store($author9);
     $book9->author_id = $a9;
     $bk9 = R::store($book9);
     $book9 = R::load("book", $bk9);
     $author = R::load("author", $book9->author_id);
     asrt($author->name, "mr Nine");
     R::trash($author);
     R::trash($book9);
     pass();
     $book2 = R::dispense("book");
     $book2->title = "second";
     R::store($book2);
     $book3 = R::dispense("book");
     $book3->title = "third";
     R::store($book3);
     asrt(count(R::find("book")), 3);
     asrt(count(R::findAll("book")), 3);
     asrt(count(R::findAll("book", " LIMIT 2")), 2);
     asrt(count(R::find("book", " id=id ")), 3);
     asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
     asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
     // Find without where clause
     asrt(count(R::findAll('book', ' order by id')), 3);
     R::trash($book3);
     R::trash($book2);
     asrt(count(R::getAll("SELECT * FROM book ")), 1);
     asrt(count(R::getCol("SELECT title FROM book ")), 1);
     asrt((int) R::getCell("SELECT 123 "), 123);
     $book = R::dispense("book");
     $book->title = "not so original title";
     $author = R::dispense("author");
     $author->name = "Bobby";
     R::store($book);
     $aid = R::store($author);
     $author = R::findOne("author", " name = ? ", array("Bobby"));
 }
开发者ID:cesium147,项目名称:redbean,代码行数:75,代码来源:Facade.php

示例15: testUploadFile

 public function testUploadFile()
 {
     $this->migrate();
     $this->login();
     // Preparation: Create an image entry.
     $image = $this->app->createModel('image', array('position' => 0));
     R::store($image);
     $this->assertNotEmpty($image->getID());
     // upload to aws s3
     $filename = 'original.jpg';
     $filepath = realpath(__DIR__ . '/' . $filename);
     $_SERVER['REQUEST_METHOD'] = "POST";
     $params = array('image_id' => $image->getID(), 'data' => '{ "id": ' . $image->getID() . ', "type": "uploadOnce", "settingName": "multiple_many_types" }', 'settingName' => 'multiple_many_types', 'uploadOnce' => 1);
     $size = filesize($filepath);
     $_FILES = array('file-0' => array('name' => $filename, 'type' => 'image/jpeg', 'tmp_name' => $filepath, 'error' => 0, 'size' => $size));
     ob_start();
     $this->app->runControllerFromRawUrl('admin/cRUDImages/uploadImage', $params);
     $output = ob_get_clean();
     echo "\nOutput of uploadImage:\n";
     echo $output;
     $output_r = json_decode($output);
     print_r($output_r);
     $this->assertFalse(property_exists($output_r[0], 'error'));
     // See if file uploaded successfully.
     echo "\nFind image with id " . $image->getID();
     $imageBean = R::findOne('image', 'id = ?', array($image->getID()));
     $this->assertNotEmpty($imageBean);
     echo "\n...Found!";
     $data = json_decode($imageBean['multiple_many_types']);
     echo "\nUploaded images:\n";
     print_r($data);
     $this->assertEquals(1, count($data));
     // Uploaded data must contain 'images/Image/1/original-smartphone'
     $this->assertNotEquals(-1, strpos(SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->smartphone), 'public/images/Image/' . $image->getID() . '/original-smartphone'));
     // Now see if file does exist in Amazon S3 repository.
     $amazonS3Config = $this->app->config('amazonS3');
     $client = \Aws\S3\S3Client::factory($amazonS3Config['settings']);
     $result = $client->getObject(array('Bucket' => $amazonS3Config['bucket'], 'Key' => SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->smartphone)));
     $this->assertNotEmpty($result['Body']);
     //        $this->app->getLogger()->log("result get object : " . print_r($result, true));
     // TEST ACL
     $resultAcl = $client->getObjectAcl(array('Bucket' => $amazonS3Config['bucket'], 'Key' => SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->smartphone)));
     //        $this->app->getLogger()->log("result get object ACL : " . print_r($resultAcl, true));
     $this->assertNotEmpty($resultAcl["Grants"]);
     $dataAcl = array();
     foreach (\Aws\S3\Model\Acp::fromArray($resultAcl->toArray()) as $grant) {
         $grantee = $grant->getGrantee();
         $dataAcl[$grantee->getGroupUri()] = array($grantee->getType(), $grant->getPermission());
     }
     $this->assertEquals(2, count($dataAcl));
     $this->assertArrayHasKey('http://acs.amazonaws.com/groups/global/AllUsers', $dataAcl);
     $this->assertEquals(array('Group', 'READ'), $dataAcl['http://acs.amazonaws.com/groups/global/AllUsers']);
     // ---- end of test ACL ----
     // Local file must have been deleted.
     $filepath = \Skully\App\Helpers\FileHelper::replaceSeparators($this->app->getTheme()->getBasePath() . $data[0]->smartphone);
     echo "\nChecking if file {$filepath} is deleted...";
     $this->assertFalse(file_exists($filepath));
     echo "\nYep";
     // Delete Models
     try {
         R::trash($imageBean);
     } catch (\Exception $e) {
         echo 'failed to delete image bean. reason: ' . $e->getMessage();
     }
     //        // Cleanup by removing files in bucket.
     //        $client->deleteObject(array(
     //            'Bucket' => $amazonS3Config['bucket'],
     //            'Key' => SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->smartphone))
     //        );
     //
     //        $client->deleteObject(array(
     //            'Bucket' => $amazonS3Config['bucket'],
     //            'Key' => SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->desktop))
     //        );
     // Check existence of deleted files on s3 server
     $result = $client->doesObjectExist($amazonS3Config['bucket'], SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->smartphone));
     $this->assertFalse($result);
     $result = $client->doesObjectExist($amazonS3Config['bucket'], SkullyAwsS3\Helpers\S3Helpers::key($this->app->config('publicDir'), $data[0]->desktop));
     $this->assertFalse($result);
 }
开发者ID:skullyframework,项目名称:skully-amazon-s3,代码行数:80,代码来源:S3Test.php


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