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
}
RedBean_OODB::init();