Example #1
0
$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();
    $bean->special = 'n';
    $bean->state = 90;
    RedBean_OODB::set($bean);