Esempio n. 1
0
function assoc($bean1, $bean2)
{
    global $assoc;
    $assoc->associate($bean1, $bean2);
    //also put a cascaded delete constraint - why not?
    RedBean_Plugin_Constraint::addConstraint($bean1, $bean2);
}
 public static function Associate($bean1, $bean2)
 {
     //Get a new association manager
     $association = new \RedBean_AssociationManager(self::Toolbox());
     //associate the bean
     $association->associate($bean1, $bean2);
     //Add acascaded delete constraint
     \RedBean_Plugin_Constraint::addConstraint($bean1, $bean2);
 }
Esempio n. 3
0
	public static function setToolBox( RedBean_ToolBox $toolbox ) {
		self::$toolbox = $toolbox;
	}
Esempio n. 4
0
$redbean->trash($whisky2);
asrt(count($a->related($whisky2, "cask")), 0);
//should be gone now!
$pdo->Execute("DROP TABLE IF EXISTS cask_whisky");
$pdo->Execute("DROP TABLE IF EXISTS cask");
$pdo->Execute("DROP TABLE IF EXISTS whisky");
//add cask 101 and whisky 12
$cask = $redbean->dispense("cask");
$cask->number = 201;
$cask2 = $redbean->dispense("cask");
$cask2->number = 202;
$a->associate($cask, $cask2);
asrt(RedBean_Plugin_Constraint::addConstraint($cask, $cask2), true, true);
asrt(RedBean_Plugin_Constraint::addConstraint($cask, $cask2), false, true);
//now from cache... no way to check if this works :(
asrt(RedBean_Plugin_Constraint::addConstraint($cask, $cask2), false, false);
asrt(count($a->related($cask, "cask")), 1);
$redbean->trash($cask2);
asrt(count($a->related($cask, "cask")), 0);
//Section D Security Tests
testpack("Test RedBean Security - bean interface ");
asrt(in_array("hack", $adapter->getCol("show tables")), true);
$bean = $redbean->load("page", "13; drop table hack");
asrt(in_array("hack", $adapter->getCol("show tables")), true);
try {
    $bean = $redbean->load("page where 1; drop table hack", 1);
} catch (Exception $e) {
}
asrt(in_array("hack", $adapter->getCol("show tables")), true);
$bean = $redbean->dispense("page");
$evil = "; drop table hack";