Example #1
0
{
}
//For short notations
if ($shortnotation_for_redbean) {
    eval("\n\t\n\t\tclass {$shortnotation_for_redbean} extends RedBean_OODB { }\n\t\n\t");
}
if ($shortnotation_for_redbeandecorator) {
    eval("\n\t\n\t\tclass {$shortnotation_for_redbeandecorator} extends RedBean_Decorator { }\n\n\t");
}
/**
 * Initialize the ADODB wrapper for MYSQL and
 * prepare RedBean OODB
 */
//get an instance of the MySQL database
if (isset($dsn)) {
    $db = PDODriver::getInstance($dsn, $username, $password, null);
} else {
    $db = MySQLDatabase::getInstance($hostname, $username, $password, $databasename);
}
if (isset($for_testing_reset_redbean)) {
    $db->Execute("drop tables dtyp,locking,patient,redbeantables,searchindex");
}
//$db->SetFetchMode(2);//RedBean uses ADO-fetch-mode 2 -- USE IF YOU REQUIRE ADO!
if ($debugmode) {
    $db->setDebugMode(1);
}
RedBean_OODB::$db = new RedBean_DBAdapter($db);
//Wrap ADO in RedBean's adapter
if ($engine) {
    RedBean_OODB::setEngine($engine);
    //select a database driver
Example #2
0
 /**
  * Kickstarts RedBean :)
  * @param $dsn
  * @param $username
  * @param $password
  * @param $freeze
  * @param $engine
  * @param $debugmode
  * @param $unlockall
  * @return unknown_type
  */
 public static function kickstart($dsn = "mysql:host=localhost;dbname=oodb", $username = '******', $password = '', $freeze = false, $engine = "innodb", $debugmode = false, $unlockall = false)
 {
     //This is no longer configurable
     eval("\n\t\t\tclass R extends RedBean_OODB { }\n\t\t");
     eval("\n\t\t\tclass RD extends RedBean_Decorator { }\n\t\t");
     //get an instance of the MySQL database
     $db = PDODriver::getInstance($dsn, $username, $password, null);
     if ($debugmode) {
         $db->setDebugMode(1);
     }
     RedBean_OODB::$db = new RedBean_DBAdapter($db);
     //Wrap ADO in RedBean's adapter
     RedBean_OODB::setEngine($engine);
     //select a database driver
     RedBean_OODB::init();
     //Init RedBean
     if ($unlockall) {
         RedBean_OODB::resetAll();
         //Release all locks
     }
     if ($freeze) {
         RedBean_OODB::freeze();
         //Decide whether to freeze the database
     }
 }