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


PHP Facade::getToolBox方法代码示例

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


在下文中一共展示了Facade::getToolBox方法的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: testDoesToolboxContainTheTools

 /**
  * Does the toolbox contain the necessary tools ?
  *
  * @return void
  */
 public function testDoesToolboxContainTheTools()
 {
     $toolbox = R::getToolBox();
     asrt($toolbox->getDatabaseAdapter() instanceof Adapter, TRUE);
     asrt($toolbox->getRedBean() instanceof OODB, TRUE);
     asrt($toolbox->getWriter() instanceof QueryWriter, TRUE);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:12,代码来源:Toolbox.php

示例3: testMySQL

 /**
  * MySQL specific tests.
  *
  * @return void
  */
 public function testMySQL()
 {
     if ($this->currentlyActiveDriverID !== 'mysql') {
         return;
     }
     testpack('Throw exception in case of issue with assoc constraint');
     $bunny = R::dispense('bunny');
     $carrot = R::dispense('carrot');
     $faultyWriter = new \FaultyWriter(R::getToolBox()->getDatabaseAdapter());
     $faultyOODB = new OODB($faultyWriter);
     $faultyOODB->setBeanHelper(R::getRedBean()->getBeanHelper());
     $faultyToolbox = new ToolBox($faultyOODB, R::getToolBox()->getDatabaseAdapter(), $faultyWriter);
     $faultyAssociationManager = new AssociationManager($faultyToolbox);
     $faultyWriter->setSQLState('23000');
     $faultyAssociationManager->associate($bunny, $carrot);
     pass();
     $faultyWriter->setSQLState('42S22');
     R::nuke();
     try {
         $faultyAssociationManager->associate($bunny, $carrot);
         fail();
     } catch (SQL $exception) {
         pass();
     }
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:30,代码来源:Association.php

示例4: testPlaysNiceWithPreExitsingSchema

 /**
  * Test integration with pre-existing schemas.
  *
  * @return void
  */
 public function testPlaysNiceWithPreExitsingSchema()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new AssociationManager($toolbox);
     $page = $redbean->dispense("page");
     $page->name = "John's page";
     $idpage = $redbean->store($page);
     $page2 = $redbean->dispense("page");
     $page2->name = "John's second page";
     $idpage2 = $redbean->store($page2);
     $a->associate($page, $page2);
     $adapter->exec("ALTER TABLE " . $writer->esc('page') . "\n\t\tCHANGE " . $writer->esc('name') . " " . $writer->esc('name') . "\n\t\tVARCHAR( 254 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL ");
     $page = $redbean->dispense("page");
     $page->name = "Just Another Page In a Table";
     $cols = $writer->getColumns("page");
     asrt($cols["name"], "varchar(254)");
     //$pdo->SethMode(1);
     $redbean->store($page);
     pass();
     // No crash?
     $cols = $writer->getColumns("page");
     asrt($cols["name"], "varchar(254)");
     //must still be same
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:33,代码来源:Preexist.php

示例5: testToString

 /**
  * Test the __toString method of the SQLHelper. 
  */
 public function testToString()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $sqlHelper = new SQLHelper($adapter);
     $sqlHelper->begin()->select('*')->from('table')->where('name = ?')->put('name');
     $str = (string) $sqlHelper;
     asrt(strpos($str, 'query') !== false, true);
     asrt(strpos($str, 'select * from table where name = ?') !== false, true);
     asrt(strpos($str, '=> Array') !== false, true);
     asrt(strpos($str, 'params') !== false, true);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:15,代码来源:Mix.php

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

示例7: testScanningAndCoding

 /**
  * Test scanning and coding of values.
  *
  * @return void
  */
 public function testScanningAndCoding()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $writer->createTable("testtable");
     $writer->addColumn("testtable", "special", CUBRID::C_DATATYPE_SPECIAL_DATE);
     $cols = $writer->getColumns("testtable");
     asrt($writer->code($cols['special'], TRUE), CUBRID::C_DATATYPE_SPECIAL_DATE);
     asrt($writer->code($cols['special'], FALSE), CUBRID::C_DATATYPE_SPECIFIED);
     $writer->addColumn("testtable", "special2", CUBRID::C_DATATYPE_SPECIAL_DATETIME);
     $cols = $writer->getColumns("testtable");
     asrt($writer->code($cols['special2'], TRUE), CUBRID::C_DATATYPE_SPECIAL_DATETIME);
     asrt($writer->code($cols['special'], FALSE), CUBRID::C_DATATYPE_SPECIFIED);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:22,代码来源:Writer.php

示例8: testDouble

 /**
  * Test storage of doubles.
  *
  * @return void
  */
 public function testDouble()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $largeDouble = 9.999998888899999E+23;
     //8.88889999922211e+17;
     $page = $redbean->dispense("page");
     $page->weight = $largeDouble;
     $id = $redbean->store($page);
     $cols = $writer->getColumns("page");
     asrt($cols["weight"], "double");
     $page = $redbean->load("page", $id);
     $page->name = "dont change the numbers!";
     $redbean->store($page);
     $page = $redbean->load("page", $id);
     $cols = $writer->getColumns("page");
     asrt($cols["weight"], "double");
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:26,代码来源:Double.php

示例9: testParamBindWithSQLite

 /**
  * Test parameter binding with SQLite.
  *
  * @return void
  */
 public function testParamBindWithSQLite()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     asrt((int) $adapter->getCell("SELECT 123"), 123);
     asrt((int) $adapter->getCell("SELECT ?", array("987")), 987);
     asrt((int) $adapter->getCell("SELECT ?+?", array("987", "2")), 989);
     asrt((int) $adapter->getCell("SELECT :numberOne+:numberTwo", array(":numberOne" => 42, ":numberTwo" => 50)), 92);
     $pair = $adapter->getAssoc("SELECT 'thekey','thevalue' ");
     asrt(is_array($pair), TRUE);
     asrt(count($pair), 1);
     asrt(isset($pair["thekey"]), TRUE);
     asrt($pair["thekey"], "thevalue");
     testpack('Test whether we can properly bind and receive NULL values');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => 'NULL')), 'NULL');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => NULL)), NULL);
     asrt($adapter->getCell('SELECT ? ', array('NULL')), 'NULL');
     asrt($adapter->getCell('SELECT ? ', array(NULL)), NULL);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:27,代码来源:Parambind.php

示例10: testObserverMechanism

 /**
  * Test RedBeanPHP observers.
  *
  * @return void
  */
 public function testObserverMechanism()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     asrt($adapter instanceof DBAdapter, TRUE);
     asrt($writer instanceof QueryWriter, TRUE);
     asrt($redbean instanceof OODB, TRUE);
     $observable = new \ObservableMock();
     $observer = new \ObserverMock();
     $observable->addEventListener("event1", $observer);
     $observable->addEventListener("event3", $observer);
     $observable->test("event1", "testsignal1");
     asrt($observer->event, "event1");
     asrt($observer->info, "testsignal1");
     $observable->test("event2", "testsignal2");
     asrt($observer->event, "event1");
     asrt($observer->info, "testsignal1");
     $observable->test("event3", "testsignal3");
     asrt($observer->event, "event3");
     asrt($observer->info, "testsignal3");
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:28,代码来源:Observers.php

示例11: testFullSupport

 /**
  * Test Full fluid UUID support.
  *
  */
 public function testFullSupport()
 {
     //Rewire objects to support UUIDs.
     $oldToolBox = R::getToolBox();
     $oldAdapter = $oldToolBox->getDatabaseAdapter();
     $uuidWriter = new \UUIDWriterPostgres($oldAdapter);
     $newRedBean = new OODB($uuidWriter);
     $newToolBox = new ToolBox($newRedBean, $oldAdapter, $uuidWriter);
     R::configureFacadeWithToolbox($newToolBox);
     list($mansion, $rooms, $ghosts, $key) = R::dispenseAll('mansion,room*3,ghost*4,key');
     $mansion->name = 'Haunted Mansion';
     $mansion->xownRoomList = $rooms;
     $rooms[0]->name = 'Green Room';
     $rooms[1]->name = 'Red Room';
     $rooms[2]->name = 'Blue Room';
     $ghosts[0]->name = 'zero';
     $ghosts[1]->name = 'one';
     $ghosts[2]->name = 'two';
     $ghosts[3]->name = 'three';
     $rooms[0]->noLoad()->sharedGhostList = array($ghosts[0], $ghosts[1]);
     $rooms[1]->noLoad()->sharedGhostList = array($ghosts[0], $ghosts[2]);
     $rooms[2]->noLoad()->sharedGhostList = array($ghosts[1], $ghosts[3], $ghosts[2]);
     $rooms[2]->xownKey = array($key);
     //Can we store a bean hierachy with UUIDs?
     R::debug(1);
     $id = R::store($mansion);
     //exit;
     asrt(is_string($id), TRUE);
     asrt(strlen($id), 36);
     $haunted = R::load('mansion', $id);
     asrt($haunted->name, 'Haunted Mansion');
     asrt(is_string($haunted->id), TRUE);
     asrt(strlen($haunted->id), 36);
     asrt(is_array($haunted->xownRoomList), TRUE);
     asrt(count($haunted->ownRoom), 3);
     $rooms = $haunted->xownRoomList;
     //Do some counting...
     $greenRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Green Room') {
             $greenRoom = $room;
             break;
         }
     }
     asrt(!is_null($greenRoom), TRUE);
     asrt(is_array($greenRoom->with(' ORDER BY id ')->sharedGhostList), TRUE);
     asrt(count($greenRoom->sharedGhostList), 2);
     $names = array();
     foreach ($greenRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,zero');
     $rooms = $haunted->xownRoomList;
     $blueRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Blue Room') {
             $blueRoom = $room;
             break;
         }
     }
     asrt(!is_null($blueRoom), TRUE);
     asrt(is_array($blueRoom->sharedGhostList), TRUE);
     asrt(count($blueRoom->sharedGhostList), 3);
     $names = array();
     foreach ($blueRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,three,two');
     $rooms = $haunted->xownRoomList;
     $redRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Red Room') {
             $redRoom = $room;
             break;
         }
     }
     $names = array();
     foreach ($redRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'two,zero');
     asrt(!is_null($redRoom), TRUE);
     asrt(is_array($redRoom->sharedGhostList), TRUE);
     asrt(count($redRoom->sharedGhostList), 2);
     //Can we repaint a room?
     $redRoom->name = 'Yellow Room';
     $id = R::store($redRoom);
     $yellowRoom = R::load('room', $id);
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
//.........这里部分代码省略.........
开发者ID:gabordemooij,项目名称:redbean,代码行数:101,代码来源:Uuid.php

示例12: testPDOParameterBinding

 /**
  * Test parameter binding with\PDO.
  * 
  * @return void
  */
 public function testPDOParameterBinding()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     R::getDatabaseAdapter()->getDatabase()->setUseStringOnlyBinding(TRUE);
     try {
         R::getAll("select * from job limit ? ", array(1));
         fail();
     } catch (\Exception $e) {
         pass();
     }
     try {
         R::getAll("select * from job limit :l ", array(":l" => 1));
         fail();
     } catch (\Exception $e) {
         pass();
     }
     try {
         R::exec("select * from job limit ? ", array(1));
         fail();
     } catch (\Exception $e) {
         pass();
     }
     try {
         R::exec("select * from job limit :l ", array(":l" => 1));
         fail();
     } catch (\Exception $e) {
         pass();
     }
     R::getDatabaseAdapter()->getDatabase()->setUseStringOnlyBinding(FALSE);
     try {
         R::getAll("select * from job limit ? ", array(1));
         pass();
     } catch (\Exception $e) {
         print_r($e);
         fail();
     }
     try {
         R::getAll("select * from job limit :l ", array(":l" => 1));
         pass();
     } catch (\Exception $e) {
         fail();
     }
     try {
         R::exec("select * from job limit ? ", array(1));
         pass();
     } catch (\Exception $e) {
         fail();
     }
     try {
         R::exec("select * from job limit :l ", array(":l" => 1));
         pass();
     } catch (\Exception $e) {
         fail();
     }
     testpack("Test findOrDispense");
     $person = R::findOrDispense("person", " job = ? ", array("developer"));
     asrt(count($person) > 0, TRUE);
     $person = R::findOrDispense("person", " job = ? ", array("musician"));
     asrt(count($person) > 0, TRUE);
     $musician = array_pop($person);
     asrt(intval($musician->id), 0);
     try {
         $adapter->exec("an invalid query");
         fail();
     } catch (SQL $e) {
         pass();
     }
     asrt((int) $adapter->getCell("SELECT 123"), 123);
     asrt((int) $adapter->getCell("SELECT ?", array("987")), 987);
     asrt((int) $adapter->getCell("SELECT ?+?", array("987", "2")), 989);
     asrt((int) $adapter->getCell("SELECT :numberOne+:numberTwo", array(":numberOne" => 42, ":numberTwo" => 50)), 92);
     $pair = $adapter->getAssoc("SELECT 'thekey','thevalue' ");
     asrt(is_array($pair), TRUE);
     asrt(count($pair), 1);
     asrt(isset($pair["thekey"]), TRUE);
     asrt($pair["thekey"], "thevalue");
     testpack('Test whether we can properly bind and receive NULL values');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => 'NULL')), 'NULL');
     asrt($adapter->getCell('SELECT :nil ', array(':nil' => NULL)), NULL);
     asrt($adapter->getCell('SELECT ? ', array('NULL')), 'NULL');
     asrt($adapter->getCell('SELECT ? ', array(NULL)), NULL);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:91,代码来源:Parambind.php

示例13: testFUSE

 /**
  * Test FUSE and model formatting.
  * 
  * @todo move tagging tests to tag tester.
  * 
  * @return void
  */
 public function testFUSE()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $blog = R::dispense('blog');
     $blog->title = 'testing';
     $blog->blog = 'tesing';
     R::store($blog);
     $blogpost = R::load("blog", 1);
     $post = R::dispense("post");
     $post->message = "hello";
     $blog->sharedPost[] = $post;
     R::store($blog);
     $a = R::getAll("select * from blog ");
     R::tag($post, "lousy,smart");
     asrt(implode(',', R::tag($post)), "lousy,smart");
     R::tag($post, "clever,smart");
     $tagz = implode(',', R::tag($post));
     asrt($tagz == "smart,clever" || $tagz == "clever,smart", TRUE);
     R::tag($blog, array("smart", "interesting"));
     asrt(implode(',', R::tag($blog)), "smart,interesting");
     try {
         R::tag($blog, array("smart", "interesting", "lousy!"));
         pass();
     } catch (RedException $e) {
         fail();
     }
     asrt(implode(',', R::tag($blog)), "smart,interesting,lousy!");
     asrt(implode(",", R::tag($blog)), "smart,interesting,lousy!");
     R::untag($blog, array("smart", "interesting"));
     asrt(implode(",", R::tag($blog)), "lousy!");
     asrt(R::hasTag($blog, array("lousy!")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart"), TRUE), FALSE);
     R::tag($blog, FALSE);
     asrt(count(R::tag($blog)), 0);
     R::tag($blog, array("funny", "comic"));
     asrt(count(R::tag($blog)), 2);
     R::addTags($blog, array("halloween"));
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("funny", "commic", "halloween"), TRUE), FALSE);
     R::unTag($blog, array("funny"));
     R::addTags($blog, "horror");
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     // No double tags
     R::addTags($blog, "horror");
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     asrt(count(R::tag($blog)), 3);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:57,代码来源:Fuse.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: DupAndCache

 /**
  * Test duplication and caching.
  *
  * @return void
  */
 public function DupAndCache()
 {
     testpack('Dup() and Cache');
     $can = R::dispense('can')->setAttr('size', 3);
     $can->ownCoffee[] = R::dispense('coffee')->setAttr('color', 'black');
     $can->sharedTag[] = R::dispense('tag')->setAttr('name', 'cool');
     $can = R::load('can', R::store($can));
     $d = new DuplicationManager(R::getToolBox());
     $d->setCacheTables(TRUE);
     ob_start();
     R::debug(1);
     $x = $d->dup($can);
     $queries = ob_get_contents();
     R::debug(0);
     ob_end_clean();
     $len1 = strlen($queries);
     asrt($len1 > 40, TRUE);
     asrt(isset($x->ownCoffee), TRUE);
     asrt(count($x->ownCoffee), 1);
     asrt(isset($x->sharedTag), TRUE);
     asrt(count($x->sharedTag), 1);
     $cache = $d->getSchema();
     R::nuke();
     $can = R::dispense('can')->setAttr('size', 3);
     $can->ownCoffee[] = R::dispense('coffee')->setAttr('color', 'black');
     $can->sharedTag[] = R::dispense('tag')->setAttr('name', 'cool');
     $can = R::load('can', R::store($can));
     $d = new DuplicationManager(R::getToolBox());
     /**
      * $cache = '{"book": {
      *  "id": "INTEGER",
      *  "title": "TEXT"
      * }, "bean": {
      *  "id": "INTEGER",
      *  "prop": "INTEGER"
      * }, "pessoa": {
      *  "id": "INTEGER",
      *  "nome": "TEXT",
      *  "nome_meio": "TEXT",
      *  "sobrenome": "TEXT",
      *  "nascimento": "NUMERIC",
      *  "reg_owner": "TEXT"
      * }, "documento": {
      *  "id": "INTEGER",
      *  "nome_documento": "TEXT",
      *  "numero_documento": "TEXT",
      *  "reg_owner": "TEXT",
      *  "ownPessoa_id": "INTEGER"
      * }, "can": {
      *  "id": "INTEGER",
      *  "size": "INTEGER"
      * }, "coffee": {
      *  "id": "INTEGER",
      *  "color": "TEXT",
      *  "can_id": "INTEGER"
      * }, "tag": {
      *  "id": "INTEGER",
      *  "name": "TEXT"
      * }, "can_tag": {
      *  "id": "INTEGER",
      *  "tag_id": "INTEGER",
      *  "can_id": "INTEGER"
      * }}'
      */
     $d->setTables($cache);
     ob_start();
     R::debug(1);
     $x = $d->dup($can);
     $queries = ob_get_contents();
     ob_end_clean();
     R::debug(0);
     $len2 = strlen($queries);
     asrt(isset($x->ownCoffee), TRUE);
     asrt(count($x->ownCoffee), 1);
     asrt(isset($x->sharedTag), TRUE);
     asrt(count($x->sharedTag), 1);
     asrt(json_encode($cache), json_encode($d->getSchema()));
     asrt($len1 > $len2, TRUE);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:84,代码来源:Dup.php


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