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


PHP Facade::nuke方法代码示例

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


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

示例1: testGetInsertID

 /**
  * Tests R::getInsertID convenience method.
  *
  * @return void
  */
 public function testGetInsertID()
 {
     R::nuke();
     $id = R::store(R::dispense('book'));
     $id2 = R::getInsertID();
     asrt($id, $id2);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:12,代码来源:Setget.php

示例2: testInnoDBIndexLimit

 /**
  * Test varchar 191 condition.
  *
  * @return void
  */
 public function testInnoDBIndexLimit()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->text = 'abcd';
     R::store($book);
     $columns = R::inspect('book');
     asrt(isset($columns['text']), TRUE);
     asrt($columns['text'], 'varchar(191)');
     $book = $book->fresh();
     $book->text = str_repeat('x', 190);
     R::store($book);
     $columns = R::inspect('book');
     asrt(isset($columns['text']), TRUE);
     asrt($columns['text'], 'varchar(191)');
     $book = $book->fresh();
     $book->text = str_repeat('x', 191);
     R::store($book);
     $columns = R::inspect('book');
     asrt(isset($columns['text']), TRUE);
     asrt($columns['text'], 'varchar(191)');
     $book = $book->fresh();
     $book->text = str_repeat('x', 192);
     R::store($book);
     $columns = R::inspect('book');
     asrt(isset($columns['text']), TRUE);
     asrt($columns['text'], 'varchar(255)');
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:33,代码来源:Issue411.php

示例3: setup

 /**
  * Setup
  * 
  * @return void
  */
 public function setup()
 {
     R::nuke();
     //Prepare structure
     $book = R::dispense('book');
     $book->title = 'book';
     $pages = R::dispense('page', 10);
     foreach ($pages as $page) {
         $page->content = 'lorem ipsum';
         $page->title = 'data';
         $page->sequence = 'data';
         $page->order = 'data';
         $page->columns = 'data';
         $page->paragraphs = 'data';
         $page->paragraphs1 = 'data';
         $page->paragraphs2 = 'data';
         $page->paragraphs3 = 'data';
         $page->paragraphs4 = 'data';
     }
     $book->xownPageList = $pages;
     $tags = R::dispense('tag', 6);
     foreach ($tags as $tag) {
         $tag->label = 'tag';
     }
     $book->sharedTagList = $tags;
     R::store($book);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:32,代码来源:Performance.php

示例4: testQueryCount

 /**
  * Test query counter.
  *
  * @return void
  */
 public function testQueryCount()
 {
     R::nuke();
     R::store(R::dispense('bean'));
     R::resetQueryCount();
     asrt(R::getQueryCount(), 0);
     R::findOne('bean');
     asrt(R::getQueryCount(), 1);
     R::resetQueryCount();
     asrt(R::getQueryCount(), 0);
     R::findOne('bean');
     R::findOne('bean');
     R::findOne('bean');
     asrt(R::getQueryCount(), 0);
     R::store(R::dispense('bean2'));
     R::resetQueryCount();
     R::findOne('bean');
     R::findOne('bean2');
     asrt(R::getQueryCount(), 2);
     R::resetQueryCount();
     R::findOne('bean', ' id < 100');
     R::findOne('bean', ' id < 101');
     R::findOne('bean', ' id < 102');
     R::findOne('bean', ' id < 103');
     asrt(R::getQueryCount(), 4);
     R::findOne('bean', ' id < 100');
     R::findOne('bean', ' id < 101');
     R::findOne('bean', ' id < 102');
     R::findOne('bean', ' id < 103');
     asrt(R::getQueryCount(), 4);
     R::findOne('bean', ' id < 104');
     asrt(R::getQueryCount(), 5);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:38,代码来源:Logging.php

示例5: testTypes

 /**
  * Test types.
  * Test how RedBeanPHP OODB and OODBBean handle type and type casts.
  * 
  * Rules:
  * 
  * 1. before storing a bean all types are preserved except booleans (they are converted to STRINGS '0' or '1')
  * 2. after store-reload all bean property values are STRINGS or NULL 
  *    (or ARRAYS but that's only from a user perspective because these are lazy loaded)
  * 3. the ID returned by store() is an INTEGER (if possible; on 32 bit systems overflowing values will be cast to STRINGS!)
  * 
  * After loading:
  * ALL VALUES EXCEPT NULL -> STRING
  * NULL -> NULL
  * 
  * @note Why not simply return bean->id in store()? Because not every driver returns the same type:
  * databases without insert_id support require a separate query or a suffix returning STRINGS, not INTEGERS.
  * 
  * @note Why not preserve types? I.e. I store integer, why do I get back a string?
  * Answer: types are handled different across database platforms, would cause overhead to inspect every value for type,
  * also PHP is a dynamically typed language so types should not matter that much. Another reason: due to the nature
  * of RB columns in the database might change (INT -> STRING) this would cause return types to change as well which would
  * cause 'cascading errors', i.e. a column gets widened and suddenly your code would break.
  * 
  * @note Unfortunately the 32/64-bit issue cannot be tested fully. Return-strategy store() is probably the safest
  * solution.
  * 
  * @return void
  */
 public function testTypes()
 {
     testpack('Beans can only contain STRING and NULL after reload');
     R::nuke();
     $bean = R::dispense('bean');
     $bean->number = 123;
     $bean->float = 12.3;
     $bean->bool = false;
     $bean->bool2 = true;
     $bean->text = 'abc';
     $bean->null = null;
     $bean->datetime = new \DateTime('NOW', new \DateTimeZone('Europe/Amsterdam'));
     $id = R::store($bean);
     asrt(is_int($id), TRUE);
     asrt(is_float($bean->float), TRUE);
     asrt(is_integer($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     $bean = R::load('bean', $id);
     asrt(is_string($bean->id), TRUE);
     asrt(is_string($bean->float), TRUE);
     asrt(is_string($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     asrt($bean->bool, '0');
     asrt($bean->bool2, '1');
 }
开发者ID:skullyframework,项目名称:skully,代码行数:62,代码来源:Typechecking.php

示例6: testUnsetParent

 /**
  * Tests whether we can NULLify a parent bean
  * page->book if the parent (book) is already
  * NULL. (isset vs array_key_exists bug).
  *
  * @return void
  */
 public function testUnsetParent()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->title = 'My Book';
     $page = R::dispense('page');
     $page->text = 'Lorem Ipsum';
     $book->ownPage[] = $page;
     R::store($book);
     $page = $page->fresh();
     R::freeze(TRUE);
     asrt((int) $page->book->id, (int) $book->id);
     unset($page->book);
     R::store($page);
     $page = $page->fresh();
     asrt((int) $page->book->id, (int) $book->id);
     $page->book = NULL;
     R::store($page);
     $page = $page->fresh();
     asrt($page->book, NULL);
     asrt($page->book_id, NULL);
     asrt($page->bookID, NULL);
     asrt($page->bookId, NULL);
     $page = R::dispense('page');
     $page->text = 'Another Page';
     $page->book = NULL;
     try {
         R::store($page);
         fail();
     } catch (\Exception $exception) {
         pass();
     }
     unset($page->book);
     R::store($page);
     $page = $page->fresh();
     $page->book = NULL;
     //this must set field id to NULL not ADD column!
     try {
         R::store($page);
         pass();
     } catch (\Exception $exception) {
         fail();
     }
     $page = $page->fresh();
     $page->book = NULL;
     R::store($page);
     $page = $page->fresh();
     asrt(is_null($page->book_id), TRUE);
     $page->book = $book;
     R::store($page);
     $page = $page->fresh();
     asrt((int) $page->book->id, (int) $book->id);
     $page->book = NULL;
     R::store($page);
     asrt(is_null($page->book_id), TRUE);
     asrt(is_null($page->book), TRUE);
     R::freeze(FALSE);
 }
开发者ID:cesium147,项目名称:redbean,代码行数:65,代码来源:Null.php

示例7: testNamedParamsInSnippets

 /**
  * Test usage of named parameters in SQL snippets.
  * Issue #299 on Github.
  *
  * @return void
  */
 public function testNamedParamsInSnippets()
 {
     testpack('Test whether we can use named parameters in SQL snippets.');
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->title = 'book';
     $book->sharedPage[] = $page;
     R::store($book);
     //should not give error like: Uncaught [HY093] - SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
     $books = $page->withCondition(' title = :title ', array(':title' => 'book'))->sharedBook;
     asrt(count($books), 1);
     //should not give error...
     $books = $page->withCondition(' title = :title ', array(':title' => 'book'))->sharedBook;
     asrt(count($books), 1);
     R::nuke();
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->title = 'book';
     $book->comment = 'comment';
     $page->title = 'page';
     $book->ownPage[] = $page;
     R::store($book);
     //should also not give error..
     $count = $book->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     //should also not give error..
     $count = $book->withCondition(' title = ? ', array('page'))->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     //should also not give error..
     $count = $book->withCondition(' title = :title ', array(':title' => 'page'))->countOwn('page');
     asrt($count, 1);
     $book = $book->fresh();
     $pages = $book->withCondition(' title = :title ', array(':title' => 'page'))->ownPage;
     asrt(count($pages), 1);
     //test with duplicate slots...
     $page = reset($pages);
     $page2 = R::dispense('page');
     $page2->ownPage[] = $page;
     R::store($page2);
     $page2 = $page2->fresh();
     $pages = $page2->withCondition(' title = :title ', array(':title' => 'page'))->ownPage;
     asrt(count($pages), 1);
     //test with find()
     $books = R::getRedBean()->find('book', array('title' => array('book')), ' AND title = :title ', array(':title' => 'book'));
     asrt(count($books), 1);
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' AND title = :title ', array(':title' => 'book'));
     asrt(count($books), 1);
     //just check numeric works as well...
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' AND title = ? ', array('book'));
     asrt(count($books), 1);
     //just extra check to verify glue works
     $books = R::getRedBean()->find('book', array('title' => array('book', 'book2'), 'comment' => array('comment', 'comment2')), ' ORDER BY id ');
     asrt(count($books), 1);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:63,代码来源:Namedparams.php

示例8: testQuickTrash

 /**
  * Tests quick trash method: R::trash( type, id ).
  *
  * @return void
  */
 public function testQuickTrash()
 {
     R::nuke();
     $bean = R::dispense('bean');
     $id = R::store($bean);
     asrt(R::count('bean'), 1);
     R::trash('bean', $id);
     asrt(R::count('bean'), 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:14,代码来源:Facade.php

示例9: testClearHist

 /**
  * Tests whether we can clear the history of a bean.
  *
  * @return void
  */
 public function testClearHist()
 {
     R::nuke();
     $book = R::dispense('book');
     asrt($book->hasChanged('title'), FALSE);
     $book->title = 'book';
     asrt($book->hasChanged('title'), TRUE);
     R::store($book);
     asrt($book->hasChanged('title'), TRUE);
     $book->clearHistory();
     asrt($book->hasChanged('title'), FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:17,代码来源:Tainted.php

示例10: testRecursiveImport

 /**
  * Test recursive imports (formely known as R::graph).
  *
  * @return void
  */
 public function testRecursiveImport()
 {
     $book = R::dispense(array('_type' => 'book', 'title' => 'The magic book', 'ownPageList' => array(array('_type' => 'page', 'content' => 'magic potions'), array('_type' => 'page', 'content' => 'magic spells'))));
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt($book->title, 'The magic book');
     $pages = $book->with(' ORDER BY content ASC ')->ownPageList;
     asrt(count($pages), 2);
     $page1 = array_shift($pages);
     asrt($page1->content, 'magic potions');
     $page2 = array_shift($pages);
     asrt($page2->content, 'magic spells');
     R::nuke();
     $book = R::dispense(array('_type' => 'book', 'title' => 'The magic book', 'author' => array('_type' => 'author', 'name' => 'Dr. Evil'), 'coAuthor' => array('_type' => 'author', 'name' => 'Dr. Creepy'), 'ownPageList' => array(array('_type' => 'page', 'content' => 'magic potions', 'ownRecipe' => array('a' => array('_type' => 'recipe', 'name' => 'Invisibility Salad'), 'b' => array('_type' => 'recipe', 'name' => 'Soup of Madness'), 'c' => array('_type' => 'recipe', 'name' => 'Love cake'))), array('_type' => 'page', 'content' => 'magic spells')), 'sharedCategory' => array(array('_type' => 'category', 'label' => 'wizardry'))));
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt($book->title, 'The magic book');
     $pages = $book->with(' ORDER BY content ASC ')->ownPageList;
     asrt(count($pages), 2);
     $page1 = array_shift($pages);
     asrt($page1->content, 'magic potions');
     $page2 = array_shift($pages);
     asrt($page2->content, 'magic spells');
     $recipes = $page1->with(' ORDER BY name ASC ')->ownRecipeList;
     asrt(count($recipes), 3);
     $recipe1 = array_shift($recipes);
     asrt($recipe1->name, 'Invisibility Salad');
     $recipe2 = array_shift($recipes);
     asrt($recipe2->name, 'Love cake');
     $recipe3 = array_shift($recipes);
     asrt($recipe3->name, 'Soup of Madness');
     $categories = $book->sharedCategoryList;
     asrt(count($categories), 1);
     $category = reset($categories);
     asrt($category->label, 'wizardry');
     asrt($book->author->name, 'Dr. Evil');
     asrt($book->fetchAs('author')->coAuthor->name, 'Dr. Creepy');
     try {
         R::dispense(array());
         fail();
     } catch (RedException $ex) {
         pass();
     }
     try {
         R::dispense(array('property' => 'value'));
         fail();
     } catch (RedException $ex) {
         pass();
     }
 }
开发者ID:cesium147,项目名称:redbean,代码行数:55,代码来源:Import.php

示例11: testEmptyCollection

 /**
  * Test empty collections (NULLCursor).
  *
  * @return void
  */
 public function testEmptyCollection()
 {
     R::nuke();
     $page = R::dispense('page');
     $page->content = 'aaa';
     R::store($page);
     $collection = R::findCollection('page');
     asrt(get_class($collection), 'RedBeanPHP\\BeanCollection');
     $collection = R::findCollection('page', ' content  =  ?', array('bbb'));
     asrt(get_class($collection), 'RedBeanPHP\\BeanCollection');
     asrt(is_null($collection->next()), TRUE);
     $collection = R::findCollection('something');
     asrt(get_class($collection), 'RedBeanPHP\\BeanCollection');
     asrt(is_null($collection->next()), TRUE);
     $collection->close();
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:21,代码来源:Cursors.php

示例12: setUp

 protected function setUp()
 {
     $config = new Config();
     $config->setProtected('basePath', BASE_PATH);
     setCommonConfig($config);
     setUniqueConfig($config);
     Application::setupRedBean('sqlite:test.db', 'user', 'password', $this->frozen, 'sqlite');
     R::freeze(false);
     R::nuke();
     R::freeze($this->frozen);
     $this->app = __setupApp();
     /** $http Mock Http object. */
     $http = $this->getMock('Skully\\Core\\Http');
     $http->expects($this->any())->method('redirect')->will($this->returnCallback('stubRedirect'));
     $this->app->setHttp($http);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:16,代码来源:DatabaseTestCase.php

示例13: testNuke

 /**
  * Nuclear test suite.
  * 
  * @return void
  */
 public function testNuke()
 {
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::getWriter()->getTables()), 1);
     R::nuke();
     asrt(count(R::getWriter()->getTables()), 0);
     $bean = R::dispense('bean');
     R::store($bean);
     asrt(count(R::getWriter()->getTables()), 1);
     R::freeze();
     R::nuke();
     // No effect
     asrt(count(R::getWriter()->getTables()), 1);
     R::freeze(FALSE);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:21,代码来源:Nuke.php

示例14: testAutoResolver

 /**
  * Tests automatic resolvement of parent beans
  * without fetchAs() using inferFetchType (foreign keys).
  *
  * @return void
  */
 public function testAutoResolver()
 {
     R::nuke();
     list($project, $teacher, $student) = R::dispenseAll('project,person,person');
     $teacher->name = 'teacher';
     $student->name = 'student';
     $project->teacher = $teacher;
     $project->student = $student;
     R::store($project);
     $project = $project->fresh();
     asrt($project->teacher instanceof OODBBean, TRUE);
     asrt($project->student instanceof OODBBean, TRUE);
     asrt($project->teacher->name, 'teacher');
     asrt($project->student->name, 'student');
     $project2 = R::dispense('project');
     $teacher2 = R::dispense('person');
     $teacher2->name = 'teacher2';
     $project2->teacher = $teacher2;
     R::store($project2);
     $project2 = $project2->fresh();
     asrt($project2->teacher instanceof OODBBean, TRUE);
     asrt($project2->teacher->name, 'teacher2');
     asrt(is_null($project2->student), TRUE);
     $project = $project->fresh();
     asrt($project->fetchAs('person')->teacher instanceof OODBBean, TRUE);
     asrt($project->fetchAs('person')->student instanceof OODBBean, TRUE);
     asrt($project->fetchAs('person')->teacher->name, 'teacher');
     asrt($project->fetchAs('person')->student->name, 'student');
     $project = $project->fresh();
     $export = R::exportAll(array($project), TRUE);
     asrt(isset($export[0]['teacher']['name']), TRUE);
     asrt(isset($export[0]['student']['name']), TRUE);
     asrt($export[0]['teacher']['name'], 'teacher');
     asrt($export[0]['student']['name'], 'student');
     //Also test the default implementation...
     $nullWriter = new \NullWriter(R::getDatabaseAdapter());
     asrt(is_null($nullWriter->inferFetchType('test', 'test')), TRUE);
     //Realteacher should take precedence over fetchAs-teacher, name conventions first!
     //also: ensure we do not use autoresolv for anything except when truly necessary! (performance)
     $realTeacher = R::dispense('teacher');
     $realTeacher->name = 'real';
     R::store($realTeacher);
     //ID must be same
     asrt($realTeacher->id, $teacher->id);
     $project = $project->fresh();
     asrt($project->teacher->name, 'real');
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:53,代码来源:Aliasing.php

示例15: 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


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