Example #1
0
 /**
  * Initializes RedBean
  * @return bool $true
  */
 public static function init($dontclose = false)
 {
     self::$me = new RedBean_OODB();
     //prepare database
     if (self::$engine === "innodb") {
         self::$db->exec("SET autocommit=0");
         self::$db->exec("START TRANSACTION");
     } else {
         if (self::$engine === "myisam") {
             self::$db->exec("SET autocommit=1");
         }
     }
     //generate the basic redbean tables
     //Create the RedBean tables we need -- this should only happen once..
     if (!self::$frozen) {
         self::$db->exec("drop tables dtyp");
         self::$db->exec("\n\t\t\tCREATE TABLE IF NOT EXISTS `dtyp` (\n\t\t\t  `id` int(11) unsigned NOT NULL auto_increment,\n\t\t\t  `tinyintus` tinyint(3) unsigned NOT NULL,\n\t\t\t  `intus` int(11) unsigned NOT NULL,\n\t\t\t  `ints` bigint(20) NOT NULL,\n\t\t\t  \n\t\t\t  `varchar255` varchar(255) NOT NULL,\n\t\t\t  `text` text NOT NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n\t\t\t");
         self::$db->exec("\n\t\t\tCREATE TABLE IF NOT EXISTS `locking` (\n\t\t\t  `tbl` varchar(255) NOT NULL,\n\t\t\t  `id` bigint(20) NOT NULL,\n\t\t\t  `fingerprint` varchar(255) NOT NULL,\n\t\t\t  `expire` int(11) NOT NULL,\n\t\t\t  UNIQUE KEY `tbl` (`tbl`,`id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1;\n\t\t\t");
         //rbt
         self::$db->exec("\n\t\t\t CREATE TABLE IF NOT EXISTS `redbeantables` (\n\t\t\t `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,\n\t\t\t `tablename` VARCHAR( 255 ) NOT NULL ,\n\t\t\t PRIMARY KEY ( `id` ),\n\t\t\t UNIQUE KEY `tablename` (`tablename`)\n\t\t\t ) ENGINE = MYISAM \n\t\t\t");
         self::$db->exec("\n\t\t\t CREATE TABLE IF NOT EXISTS `searchindex` (\n\t\t\t`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,\n\t\t\t`ind` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`cnt` INT( 11 ) NOT NULL ,\n\t\t\tPRIMARY KEY ( `id` ),\n\t\t\tUNIQUE KEY `ind` (`ind`)\n\t\t\t) ENGINE = MYISAM ");
     }
     //generate a key
     if (!self::$pkey) {
         self::$pkey = str_replace(".", "", microtime(true) . "" . mt_rand());
     }
     return true;
 }