/** * Returns the parent of a bean. * @param RedBean_OODBBean $bean * @return RedBean_OODBBean $bean */ public static function getParent(RedBean_OODBBean $bean) { return self::$treeManager->getParent($bean); }
/** * * @param RedBean_DomainObject $other */ protected function attach(RedBean_DomainObject $other) { $this->treeManager->attach($this->bean, $other->bean); }
pass(); //no error $a->associate($user, $page); pass(); asrt(count($a->related($user, "page")), 1); asrt(count($a->related($page, "user")), 1); $a->clearRelations($user, "page"); pass(); //no error asrt(count($a->related($user, "page")), 0); asrt(count($a->related($page, "user")), 0); $page = $redbean->load("page", $id); pass(); asrt($page->name, "test page"); testpack("Test: Trees "); $tm = new RedBean_TreeManager($toolbox); $subpage1 = $redbean->dispense("page"); $subpage2 = $redbean->dispense("page"); $subpage3 = $redbean->dispense("page"); $tm->attach($page, $subpage1); asrt(count($tm->children($page)), 1); $tm->attach($page, $subpage2); asrt(count($tm->children($page)), 2); $tm->attach($subpage2, $subpage3); asrt(count($tm->children($page)), 2); asrt(count($tm->children($subpage2)), 1); asrt(intval($subpage1->parent_id), intval($id)); testpack("Test Integration Pre-existing Schema"); $adapter->exec("ALTER TABLE `page` CHANGE `name` `name` VARCHAR( 254 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL "); $page = $redbean->dispense("page"); $page->name = "Just Another Page In a Table";