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


PHP R::dependencies方法代码示例

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


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

示例1: testRebuilder

 /**
  * Test SQLite table rebuilding.
  * 
  * @return void
  */
 public function testRebuilder()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     R::dependencies(array('page' => array('book')));
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 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->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 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:daviddeutsch,项目名称:redbean-adaptive,代码行数:36,代码来源:Rebuild.php

示例2: testDependency4

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

示例3: testGraph

    /**
     * Test graph() method.
     * 
     * @return void
     */
    public function testGraph()
    {
        RedBean_Plugin_Cooker::enableBeanLoading(TRUE);
        R::dependencies(array());
        $currentDriver = $this->currentlyActiveDriverID;
        global $lifeCycle;
        $toolbox = R::$toolbox;
        $adapter = $toolbox->getDatabaseAdapter();
        $writer = $toolbox->getWriter();
        $redbean = $toolbox->getRedBean();
        try {
            R::graph(array(array(array('a' => 'b'))));
            fail();
        } catch (RedBean_Exception_Security $e) {
            pass();
        }
        try {
            R::graph('ABC');
            fail();
        } catch (RedBean_Exception_Security $e) {
            pass();
        }
        try {
            R::graph(123);
            fail();
        } catch (RedBean_Exception_Security $e) {
            pass();
        }
        try {
            R::graph(array(new stdClass()));
            fail();
        } catch (RedBean_Exception_Security $e) {
            pass();
        }
        list($v1, $v2, $v3) = R::dispense('village', 3);
        list($b1, $b2, $b3, $b4, $b5, $b6) = R::dispense('building', 6);
        list($f1, $f2, $f3, $f4, $f5, $f6) = R::dispense('farmer', 6);
        list($u1, $u2, $u3, $u4, $u5, $u6) = R::dispense('furniture', 6);
        list($a1, $a2) = R::dispense('army', 2);
        $a1->strength = 100;
        $a2->strength = 200;
        $v1->name = 'v1';
        $v2->name = 'v2';
        $v3->name = 'v3';
        $v1->ownBuilding = array($b4, $b6);
        $v2->ownBuilding = array($b1);
        $v3->ownBuilding = array($b5);
        $b1->ownFarmer = array($f1, $f2);
        $b6->ownFarmer = array($f3);
        $b5->ownFarmer = array($f4);
        $b5->ownFurniture = array($u6, $u5, $u4);
        $v2->sharedArmy[] = $a2;
        $v3->sharedArmy = array($a2, $a1);
        $i2 = R::store($v2);
        $i1 = R::store($v1);
        $i3 = R::store($v3);
        $v1 = R::load('village', $i1);
        $v2 = R::load('village', $i2);
        $v3 = R::load('village', $i3);
        asrt(count($v3->ownBuilding), 1);
        asrt(count(reset($v3->ownBuilding)->ownFarmer), 1);
        asrt(count(reset($v3->ownBuilding)->ownFurniture), 3);
        asrt(count($v3->sharedArmy), 2);
        asrt(count($v1->sharedArmy), 0);
        asrt(count($v2->sharedArmy), 1);
        asrt(count($v2->ownBuilding), 1);
        asrt(count($v1->ownBuilding), 2);
        asrt(count(reset($v1->ownBuilding)->ownFarmer), 0);
        asrt(count(end($v1->ownBuilding)->ownFarmer), 1);
        asrt(count($v3->ownTapestry), 0);
        // Change the names and add the same building should not change the graph
        $v1->name = 'village I';
        $v2->name = 'village II';
        $v3->name = 'village III';
        $v1->ownBuilding[] = $b4;
        $i2 = R::store($v2);
        $i1 = R::store($v1);
        $i3 = R::store($v3);
        $v1 = R::load('village', $i1);
        $v2 = R::load('village', $i2);
        $v3 = R::load('village', $i3);
        asrt(count($v3->ownBuilding), 1);
        asrt(count(reset($v3->ownBuilding)->ownFarmer), 1);
        asrt(count(reset($v3->ownBuilding)->ownFurniture), 3);
        asrt(count($v3->sharedArmy), 2);
        asrt(count($v1->sharedArmy), 0);
        asrt(count($v2->sharedArmy), 1);
        asrt(count($v2->ownBuilding), 1);
        asrt(count($v1->ownBuilding), 2);
        asrt(count(reset($v1->ownBuilding)->ownFarmer), 0);
        asrt(count(end($v1->ownBuilding)->ownFarmer), 1);
        asrt(count($v3->ownTapestry), 0);
        $b = reset($v1->ownBuilding);
        R::trash($b);
        $n = R::count('village');
//.........这里部分代码省略.........
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:101,代码来源:Graph.php

示例4: testListAddDelete

 /**
  * Test list add and delete.
  * 
  * @return void
  */
 public function testListAddDelete()
 {
     testpack('Test list add/delete scenarios.');
     R::dependencies(array('page' => array('book', 'paper')));
     $b = R::dispense('book');
     $p = R::dispense('page');
     $b->title = 'a';
     $p->name = 'b';
     $b->ownPage[] = $p;
     R::store($b);
     $b->ownPage = array();
     R::store($b);
     asrt(R::count('page'), 0);
     $p = R::dispense('page');
     $z = R::dispense('paper');
     $z->ownPage[] = $p;
     R::store($z);
     asrt(R::count('page'), 1);
     $z->ownPage = array();
     R::store($z);
     asrt(R::count('page'), 0);
     $i = R::dispense('magazine');
     $i->ownPage[] = R::dispense('page');
     R::store($i);
     asrt(R::count('page'), 1);
     $i->ownPage = array();
     R::store($i);
     asrt(R::count('page'), 1);
     R::dependencies(array());
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:35,代码来源:Relations.php


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