$db->exec("INSERT INTO `redbeantables` (\n`id` ,\n`tablename`\n)\nVALUES (\nNULL , 'slimtable'\n);\n"); $db->exec("INSERT INTO `slimtable` (\n`id` ,\n`col1` ,\n`col2` ,\n`col3`\n)\nVALUES (\nNULL , '1', 'mustbevarchar', '1000'\n);\n"); $db->exec("\nCREATE TABLE `indexer` (\n`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,\n`highcard` VARCHAR( 255 ) NOT NULL ,\n`lowcard` TEXT NOT NULL ,\n`lowcard2` INT( 11 ) NOT NULL ,\n`highcard2` LONGTEXT NOT NULL ,\nPRIMARY KEY ( `id` )\n) ENGINE = MYISAM"); $db->exec("INSERT INTO `redbeantables` (\n`id` ,\n`tablename`\n)\nVALUES (\nNULL , 'indexer'\n);\n"); for ($i = 0; $i < 20; $i++) { $db->exec("INSERT INTO `indexer` (\n`id` ,\n`highcard` ,\n`lowcard` ,\n`lowcard2`,\n`highcard2`\n)\nVALUES (\nNULL , rand(), 'a', rand(), CONCAT( rand()*100, '" . str_repeat('x', 1000) . "' )\n);\n"); } for ($i = 0; $i < 500; $i++) { RedBean_OODB::keepInShape(); } $row = $db->getRow("select * from slimtable limit 1"); SmartTest::test($row["col1"], 1); SmartTest::test($row["col2"], "mustbevarchar"); SmartTest::test($row["col3"], 1000); SmartTest::test(count($db->get("describe slimtable")), 4); RedBean_OODB::dropColumn("slimtable", "col3"); SmartTest::test(count($db->get("describe slimtable")), 3); RedBean_OODB::KeepInShape(true); $tables = RedBean_OODB::showTables(); SmartTest::test(in_array("slimtable", $tables), false); //Tests for each individual engine function testsperengine() { global $tests; SmartTest::instance()->progress(); SmartTest::instance()->testPack = "perform generic bean manipulation"; $ok = 1; $bean = RedBean_OODB::dispense("note"); $bean->message = "hai"; $bean->color = 3; $bean->date = time();
/** * Free memory of a class, drop column in db * @param $property * @return unknown_type */ public function free($property) { RedBean_OODB::dropColumn($this->type, $property); }