public static function Toolbox()
 {
     //if not the first time this is called
     if (isset(self::$toolbox)) {
         return self::$toolbox;
     }
     //else set up the RedBean toolbox
     require_once \Swiftriver\Core\Setup::Configuration()->ModulesDirectory . "/RedBean/redbean.inc.php";
     //get the url of the url of the db server
     $url = (string) Setup::$Configuration->DataBaseUrl;
     //Get the db username
     $username = (string) Setup::$Configuration->UserName;
     //get the password
     $password = (string) Setup::$Configuration->Password;
     //get the db name
     $database = (string) Setup::$Configuration->Database;
     //set the db type
     $typeofdatabase = "mysql";
     //Assemble a database connection string (DSN)
     $dsn = "{$typeofdatabase}:host={$url};dbname={$database}";
     //Construct a new Red Bean Toolbox, if it has not been set in the mean time
     if (!isset(self::$toolbox)) {
         self::$toolbox = \RedBean_Setup::kickstartDev($dsn, $username, $password);
     }
     //return it
     return self::$toolbox;
 }
Пример #2
0
<?php

/*
init.php
Redbean initializator
Mochammad Masbuchin
*/
require "RedBean/redbean.inc.php";
$toolbox = RedBean_Setup::kickstartDev("mysql:host=localhost;dbname=restobean", "root", "");
$redbean = $toolbox->getRedBean();
$pegawai = $redbean->dispense("pegawai");
$menu = $redbean->dispense("menu");
$cashierin = $redbean->dispense("cashierin");
$cashierout = $redbean->dispense("cashierout");
$order = $redbean->dispense("order");
$ordermenu = $redbean->dispense("ordermenu");
$settle = $redbean->dispense("settle");
$bahan = $redbean->dispense("bahan");
$stockhistory = $redbean->dispense("stockhistory");
$resep = $redbean->dispense("resep");
$keuangan = $redbean->dispense("keuangan");
$payout = $redbean->dispense("payout");
$adapter = $toolbox->getDatabaseAdapter();
//$meja->import($lesehan, "namameja, jumlahkursi, status, lokasi");
/*$meja->import($pendopo, "namameja, jumlahkursi, status, lokasi");
print_r($meja);*/
Пример #3
0
}
//If you did not specify a username, we do this for you
if (!isset($username)) {
    $username = "******";
}
//If you did not specify a database type, we will use mysql
if (!isset($typeofdatabase)) {
    $typeofdatabase = "mysql";
}
//Assemble a database connection string (DSN)
$dsn = "{$typeofdatabase}:host=localhost;dbname={$database}";
//Connect to database and fetch the toolbox; either with or without password
if (!isset($password)) {
    $toolbox = RedBean_Setup::kickstartDev($dsn, $username);
} else {
    $toolbox = RedBean_Setup::kickstartDev($dsn, $username, $password);
}
//Extracting tools for you
$redbean = $toolbox->getRedBean();
$db = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
//Creating an Association Manager for you
$assoc = new RedBean_AssociationManager($toolbox);
//Creating a Tree Manager for you
$tree = new RedBean_TreeManager($toolbox);
function assoc($bean1, $bean2)
{
    global $assoc;
    $assoc->associate($bean1, $bean2);
    //also put a cascaded delete constraint - why not?
    RedBean_Plugin_Constraint::addConstraint($bean1, $bean2);