コード例 #1
0
ファイル: oodb.php プロジェクト: Jamongkad/Sunfish
 /**
  * Closes and unlocks the bean
  * @return unknown_type
  */
 public function __destruct()
 {
     //prepare database
     if (self::$engine === "innodb") {
         self::$db->exec("COMMIT");
     } else {
         if (self::$engine === "myisam") {
             //nope
         }
     }
     RedBean_OODB::gc();
     RedBean_OODB::releaseAllLocks();
     //echo "destructor has been invoked";
 }
コード例 #2
0
ファイル: test.php プロジェクト: Jamongkad/Sunfish
$db->exec(" CREATE TABLE `oodb`.`garbage1` (\n\t\t\t`a` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`b` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`c` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`d` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`e` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`f` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`g` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`h` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`i` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`j` VARCHAR( 11 ) NOT NULL\n\t\t\t) ENGINE = MYISAM ");
//insert garbage tables
$db->exec(" CREATE TABLE `oodb`.`garbage2` (\n\t\t\t`a` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`b` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`c` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`d` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`e` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`f` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`g` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`h` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`i` VARCHAR( 11 ) NOT NULL ,\n\t\t\t`j` VARCHAR( 11 ) NOT NULL\n\t\t\t) ENGINE = MYISAM ");
$db->exec("INSERT INTO `oodb`.`garbage1` (\n\t\t\t`a` ,\n\t\t\t`b` ,\n\t\t\t`c` ,\n\t\t\t`d` ,\n\t\t\t`e` ,\n\t\t\t`f` ,\n\t\t\t`g` ,\n\t\t\t`h` ,\n\t\t\t`i` ,\n\t\t\t`j`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t'aaa', 'bbb', 'cccc', 'dddd', 'eee', '', 'fff', 'ggg', '', 'hhh'\n\t\t\t);\n");
Redbean_OODB::addTable("garbage1");
Redbean_OODB::addTable("garbage2");
$cols = $db->get("describe garbage1");
$ok = 0;
if (count($cols) === 10) {
    SmartTest::instance()->progress();
}
if (RedBean_OODB::gc()) {
    SmartTest::instance()->progress();
}
for ($i = 0; $i < 100; $i++) {
    RedBean_OODB::gc();
}
$cols = $db->get("describe garbage1");
if (count($cols) === 8) {
    $ok = 1;
    SmartTest::instance()->progress();
}
$tables = $db->get("show tables");
foreach ($tables as $t) {
    if ($t == "garbage2") {
        $ok = 0;
    }
}
if (!$ok) {
    die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
}