예제 #1
0
파일: oodb.php 프로젝트: Jamongkad/Sunfish
 * 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();
//Init RedBean
if ($unlockall) {
    RedBean_OODB::resetAll();
    //Release all locks
}
if ($freeze) {
    RedBean_OODB::freeze();
    //Decide whether to freeze the database
}
예제 #2
0
파일: oodb.php 프로젝트: seanhess/redbean
 /**
  * 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
     }
 }