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


PHP Facade::freeze方法代码示例

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


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

示例1: testTwoWordsUnderscoredBean

 /**
  * Cant have underscored beans
  * @expectedException \RedBeanPHP\RedException
  */
 public function testTwoWordsUnderscoredBean()
 {
     R::freeze(false);
     $testName = R::dispense('test_name');
     $id = R::store($testName);
     R::load('test_name', $id);
     R::freeze($this->frozen);
 }
开发者ID:skullyframework,项目名称:project,代码行数:12,代码来源:ModelTest.php

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

示例3: testBatch

 /**
  * Begin testing.
  * This method runs the actual test pack.
  *
  * @return void
  */
 public function testBatch()
 {
     R::freeze(FALSE);
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     $page->name = "page no. 1";
     $page->rating = 1;
     $id1 = $redbean->store($page);
     $page = $redbean->dispense("page");
     $page->name = "page no. 2";
     $id2 = $redbean->store($page);
     $batch = $redbean->batch("page", array($id1, $id2));
     asrt(count($batch), 2);
     asrt($batch[$id1]->getMeta("type"), "page");
     asrt($batch[$id2]->getMeta("type"), "page");
     asrt((int) $batch[$id1]->id, $id1);
     asrt((int) $batch[$id2]->id, $id2);
     $book = $redbean->dispense("book");
     $book->name = "book 1";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 2";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 3";
     $redbean->store($book);
     $books = $redbean->batch("book", $adapter->getCol("SELECT id FROM book"));
     asrt(count($books), 3);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     $a = $redbean->batch('triangle', 1);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     R::freeze(TRUE);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     try {
         $a = $redbean->batch('triangle', 1);
         fail();
     } catch (SQL $e) {
         pass();
     }
     R::freeze(FALSE);
     asrt(R::wipe('spaghettimonster'), FALSE);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:57,代码来源:Batch.php

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

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

示例6: testCountAndWipe

 /**
  * Test count and wipe.
  *
  * @return void
  */
 public function testCountAndWipe()
 {
     testpack("Test count and wipe");
     $page = R::dispense("page");
     $page->name = "ABC";
     R::store($page);
     $n1 = R::count("page");
     $page = R::dispense("page");
     $page->name = "DEF";
     R::store($page);
     $n2 = R::count("page");
     asrt($n1 + 1, $n2);
     R::wipe("page");
     asrt(R::count("page"), 0);
     asrt(R::getRedBean()->count("page"), 0);
     asrt(R::getRedBean()->count("kazoo"), 0);
     // non existing table
     R::freeze(TRUE);
     asrt(R::getRedBean()->count("kazoo"), 0);
     // non existing table
     R::freeze(FALSE);
     $page = R::dispense('page');
     $page->name = 'foo';
     R::store($page);
     $page = R::dispense('page');
     $page->name = 'bar';
     R::store($page);
     asrt(R::count('page', ' name = ? ', array('foo')), 1);
     // Now count something that does not exist, this should return 0. (just be polite)
     asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
     asrt(R::count('teapot'), 0);
     $currentDriver = $this->currentlyActiveDriverID;
     // Some drivers don't support that many error codes.
     if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
         try {
             R::count('teaport', ' for tea ');
             fail();
         } catch (SQL $e) {
             pass();
         }
     }
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:47,代码来源:Count.php

示例7: setUp

 protected function setUp()
 {
     $config = new Config();
     $config->setProtected('basePath', BASE_PATH);
     setCommonConfig($config);
     setUniqueConfig($config);
     $dbConfig = $config->getProtected('dbConfig');
     if ($dbConfig['type'] == 'mysql') {
         Application::setupRedBean("mysql:host={$dbConfig['host']};dbname={$dbConfig['dbname']};port={$dbConfig['port']}", $dbConfig['user'], $dbConfig['password'], $config->getProtected('isDevMode'));
     } elseif ($dbConfig['type'] == 'sqlite') {
         Application::setupRedBean("sqlite:{$dbConfig['dbname']}", $dbConfig['user'], $dbConfig['password'], $config->getProtected('isDevMode'));
     }
     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,项目名称:project,代码行数:21,代码来源:DatabaseTestCase.php

示例8: testUnsetAliasedParent

 /**
  * Test nullifying aliased parent.
  *
  * @return void
  */
 public function testUnsetAliasedParent()
 {
     R::nuke();
     $book = R::dispense('book');
     $author = R::dispense('author');
     $book->coauthor = $author;
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), FALSE);
     unset($book->coauthor);
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), FALSE);
     $book->coauthor = NULL;
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), TRUE);
     R::trash($book);
     R::trash($author);
     R::freeze(TRUE);
     $book = R::dispense('book');
     $author = R::dispense('author');
     $book->coauthor = $author;
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), FALSE);
     unset($book->coauthor);
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), FALSE);
     $book->coauthor = NULL;
     R::store($book);
     $book = $book->fresh();
     asrt(is_null($book->fetchAs('author')->coauthor), TRUE);
     R::trash($book);
     R::trash($author);
     R::freeze(FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:43,代码来源:Xnull.php

示例9: testLoadNonExistant

 /**
  * Tests whether loading non-existant beans
  * returns the same results in frozen mode.
  *
  * @return
  */
 public function testLoadNonExistant()
 {
     R::nuke();
     R::store(R::dispense('bean'));
     R::freeze(TRUE);
     $bean = R::load('bean', 123);
     R::freeze(FALSE);
     asrt($bean instanceof OODBBean, TRUE);
     asrt($bean->id, 0);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:16,代码来源:Frozen.php

示例10: function

<?php

// Error reporting
//error_reporting(E_ALL ^ E_NOTICE);
// SlimPHP portable route fix
$_SERVER['SCRIPT_NAME'] = preg_replace('/public\\/index\\.php$/', 'index.php', $_SERVER['SCRIPT_NAME'], 1);
// RedBeanPHP alias fix
use RedBeanPHP\Facade as R;
// Load Config
require 'app/config.php';
// Autoload
require 'vendor/autoload.php';
// RedBeanPHP setup
R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD);
R::freeze(DB_FREEZE);
// Slim app instance
$app = new \Slim\Slim();
// Slim Config
$app->config(['templates.path' => 'app/views', 'debug' => APP_DEBUG]);
// Set webroot for portable
$app->hook('slim.before', function () use($app) {
    $app->wroot = $app->request->getUrl() . $app->request->getRootUri();
    $app->view()->appendData(array('wroot' => $app->wroot));
});
// HybridAuth instance
$app->container->singleton('hybridInstance', function ($app) {
    $config = ["base_url" => $app->wroot . "/cb", "providers" => ["Facebook" => ["enabled" => true, "keys" => ["id" => FB_ID, "secret" => FB_SECRET], "scope" => "email, user_about_me, user_birthday, user_location", "trustForwarded" => false], "Twitter" => ["enabled" => true, "keys" => ["key" => TW_KEY, "secret" => TW_SECRET]]], "debug_mode" => HYBRIDAUTH_DEBUG_MODE, "debug_file" => HYBRIDAUTH_DEBUG_FILE];
    $instance = new Hybrid_Auth($config);
    return $instance;
});
// Auth Check
开发者ID:rodrigopolo,项目名称:HybridAuthDemo,代码行数:31,代码来源:app.php

示例11: prepare

 /**
  * Prepare test pack (mostly: nuke the entire database)
  */
 public function prepare()
 {
     R::freeze(FALSE);
     R::debug(FALSE);
     R::nuke();
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:9,代码来源:RedUNIT.php

示例12: ConfigSetup

 public static function ConfigSetup($arrconfig = null)
 {
     if (is_array($arrconfig) && !empty($arrconfig)) {
         if ($arrconfig['server']) {
             self::$server = $arrconfig['server'];
         }
         if ($arrconfig['databasename']) {
             self::$databasename = $arrconfig['databasename'];
         }
         if ($arrconfig['username']) {
             self::$username = $arrconfig['username'];
         }
         if ($arrconfig['password']) {
             self::$password = $arrconfig['password'];
         }
         if ($arrconfig['port']) {
             self::$port = $arrconfig['port'];
         }
     }
     self::$connection = new PDO('mysql:host=' . self::$server . ';port=' . self::$port . ';dbname=' . self::$databasename . ';', self::$username, self::$password);
     self::$connection->query('SET NAMES utf8');
     R::setup(self::$connection);
     R::freeze(true);
     self::$logsrv = new \RedBeanPHP\Plugin\SystemlogsService();
     R::debug(true, 1);
 }
开发者ID:limweb,项目名称:webappservice,代码行数:26,代码来源:AMFUtil.php

示例13: testFunctionFilters

 /**
  * Test Facade bind function method.
  * Test for MySQL WKT spatial format.
  */
 public function testFunctionFilters()
 {
     R::nuke();
     R::bindFunc('read', 'location.point', 'asText');
     R::bindFunc('write', 'location.point', 'GeomFromText');
     R::store(R::dispense('location'));
     R::freeze(true);
     try {
         R::find('location');
         fail();
     } catch (SQL $exception) {
         pass();
     }
     R::freeze(false);
     try {
         R::find('location');
         pass();
     } catch (SQL $exception) {
         fail();
     }
     $location = R::dispense('location');
     $location->point = 'POINT(14 6)';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'point');
     $location = $location->fresh();
     asrt($location->point, 'POINT(14 6)');
     R::nuke();
     $location = R::dispense('location');
     $location->point = 'LINESTRING(0 0,1 1,2 2)';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'linestring');
     $location->bustcache = 2;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point, 'LINESTRING(0 0,1 1,2 2)');
     R::nuke();
     $location = R::dispense('location');
     $location->point = 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'polygon');
     $location->bustcache = 4;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point, 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))');
     R::bindFunc('read', 'location.point', NULL);
     $location->bustcache = 1;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point === 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))', FALSE);
     $filters = AQueryWriter::getSQLFilters();
     asrt(is_array($filters), TRUE);
     asrt(count($filters), 2);
     asrt(isset($filters[QueryWriter::C_SQLFILTER_READ]), TRUE);
     asrt(isset($filters[QueryWriter::C_SQLFILTER_WRITE]), TRUE);
     R::bindFunc('read', 'place.point', 'asText');
     R::bindFunc('write', 'place.point', 'GeomFromText');
     R::bindFunc('read', 'place.line', 'asText');
     R::bindFunc('write', 'place.line', 'GeomFromText');
     R::nuke();
     $place = R::dispense('place');
     $place->point = 'POINT(13.2 666.6)';
     $place->line = 'LINESTRING(9.2 0,3 1.33)';
     R::store($place);
     $columns = R::inspect('place');
     asrt($columns['point'], 'point');
     asrt($columns['line'], 'linestring');
     $place = R::findOne('place');
     asrt($place->point, 'POINT(13.2 666.6)');
     asrt($place->line, 'LINESTRING(9.2 0,3 1.33)');
     R::bindFunc('read', 'place.point', NULL);
     R::bindFunc('write', 'place.point', NULL);
     R::bindFunc('read', 'place.line', NULL);
     R::bindFunc('write', 'place.line', NULL);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:81,代码来源:Writer.php

示例14: testTransactions

 /**
  * Test Transactions.
  *
  * @return void
  */
 public function testTransactions()
 {
     testpack('transactions');
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::commit();
     asrt(R::count('bean'), 1);
     R::wipe('bean');
     R::freeze(1);
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::rollback();
     asrt(R::count('bean'), 0);
     R::freeze(FALSE);
     testpack('genSlots');
     asrt(R::genSlots(array('a', 'b')), '?,?');
     asrt(R::genSlots(array('a')), '?');
     asrt(R::genSlots(array()), '');
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:26,代码来源:Misc.php

示例15: testChillTest

 /**
  * Test whether we can set and reset the chill list and check the contents
  * of the chill list.
  *
  * @return void
  */
 public function testChillTest()
 {
     R::freeze(array('beer'));
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(FALSE);
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(TRUE);
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), TRUE);
     asrt($oodb->isChilled('wine'), FALSE);
     R::freeze(array());
     $oodb = R::getRedBean();
     asrt($oodb->isChilled('beer'), FALSE);
     asrt($oodb->isChilled('wine'), FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:25,代码来源:Chill.php


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