コード例 #1
0
 /**
  * Begin testing.
  * This method runs the actual test pack.
  *
  * @return void
  */
 public function testBatch()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     $page->name = "page no. 1";
     $page->rating = 1;
     $id1 = $redbean->store($page);
     $page = $redbean->dispense("page");
     $page->name = "page no. 2";
     $id2 = $redbean->store($page);
     $batch = $redbean->batch("page", array($id1, $id2));
     asrt(count($batch), 2);
     asrt($batch[$id1]->getMeta("type"), "page");
     asrt($batch[$id2]->getMeta("type"), "page");
     asrt((int) $batch[$id1]->id, $id1);
     asrt((int) $batch[$id2]->id, $id2);
     $book = $redbean->dispense("book");
     $book->name = "book 1";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 2";
     $redbean->store($book);
     $book = $redbean->dispense("book");
     $book->name = "book 3";
     $redbean->store($book);
     $books = $redbean->batch("book", $adapter->getCol("SELECT id FROM book"));
     asrt(count($books), 3);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     $a = $redbean->batch('triangle', 1);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     R::freeze(TRUE);
     $a = $redbean->batch('book', 9919);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     $a = $redbean->batch('triangle', 1);
     asrt(is_array($a), TRUE);
     asrt(count($a), 0);
     R::freeze(FALSE);
     asrt(R::wipe('spaghettimonster'), FALSE);
 }
コード例 #2
0
 /**
  * Test count and wipe.
  * 
  * @return void
  */
 public function testCountAndWipe()
 {
     testpack("Test count and wipe");
     $page = R::dispense("page");
     $page->name = "ABC";
     R::store($page);
     $n1 = R::count("page");
     $page = R::dispense("page");
     $page->name = "DEF";
     R::store($page);
     $n2 = R::count("page");
     asrt($n1 + 1, $n2);
     R::wipe("page");
     asrt(R::count("page"), 0);
     asrt(R::$redbean->count("page"), 0);
     asrt(R::$redbean->count("kazoo"), 0);
     // non existing table
     R::freeze(TRUE);
     asrt(R::$redbean->count("kazoo"), 0);
     // non existing table
     R::freeze(FALSE);
     $page = R::dispense('page');
     $page->name = 'foo';
     R::store($page);
     $page = R::dispense('page');
     $page->name = 'bar';
     R::store($page);
     asrt(R::count('page', ' name = ? ', array('foo')), 1);
     // Now count something that does not exist, this should return 0. (just be polite)
     asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
     asrt(R::count('teapot'), 0);
     $currentDriver = $this->currentlyActiveDriverID;
     // Some drivers don't support that many error codes.
     if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
         try {
             R::count('teaport', ' for tea ');
             fail();
         } catch (RedBean_Exception_SQL $e) {
             pass();
         }
     }
 }
コード例 #3
0
ファイル: routing.php プロジェクト: michalsen/sfapi
<?php

/**
 *  GNL/SF Routing
 */
/**
 *  Updating SF Credentials
 *
 */
if (isset($_REQUEST['sf_credentials'])) {
    //print_r($_REQUEST);
    R::wipe('sfcredentials');
    $creds = R::dispense('sfcredentials');
    $creds->usr = $_REQUEST['usr'];
    $creds->pwd = $_REQUEST['pwd'];
    $creds->key = $_REQUEST['key'];
    $id = R::store($creds);
}
/**
 *  Create admin page
 */
if ($_SERVER['REQUEST_URI'] == '/') {
    if (isset($_SESSION['loggedin'])) {
        require 'page.tpl.php';
    } else {
        require 'login.tpl.php';
    }
}
/*
A Few Phone Call Leads:
465314 - *
コード例 #4
0
ファイル: reset.php プロジェクト: hajnalben/SoundsAndColors
<?php

require './rb.php';
R::setup('mysql:host=192.168.56.154;dbname=c9hallhatoszinek', 'c9hallhatoszinek', 'justNow465');
R::wipe("user");
R::wipe("sound");
コード例 #5
0
ファイル: api.php プロジェクト: TheRealPino/FDS-Online
        } else {
            return FALSE;
        }
    }
});
/**
 * @api {get} /api/v1/wipe/ Erases all jobs.
 * @apiDescription Erases all jobs (Testing purposes only).
 * @apiGroup wipe
 * @apiName WipeJobs
 * @apiVersion 1.0.0
 * @apiExample {curl} Example usage:
 *      curl 'http://pyro.demo/api/v1/wipe'
 */
$app->get('/api/v1/wipe/', function () use($app) {
    R::wipe("job");
    echo "The jobs have been wiped.";
});
/**
 * @api {get} /api/v1/kill/:id Kills a job.
 * @apiDescription Kills a currently running job.
 * @apiGroup kill
 * @apiName KillJob
 * @apiVersion 1.0.0
 * @apiExample {curl} Example usage:
 *      curl 'http://pyro.demo/api/v1/kill/1
 * @apiSuccess (200 OK) {String} A string indicating kill and delete were successful.
 * @apiError (400 Bad Request) {String) A string indicating the job does not exist.
 */
$app->get('/api/v1/kill/:id', function ($id) use($app) {
    $job = DB::GetJob($id);
コード例 #6
0
ファイル: ScheduleManager.php プロジェクト: karlosos/sci_plan
 /**
  * Updating class rooms from list.
  *
  * @param array $array Class rooms list
  */
 private function updateRoomList($array)
 {
     R::wipe('sale');
     //print_r($array);
     foreach ($array as $salax) {
         //print_r($salax);
         R::useWriterCache(true);
         $classroom = R::dispense('sale');
         $legacy_id = $salax[0];
         $legacy_id = substr($legacy_id, 0, strlen($legacy_id) - 5);
         $legacy_id = substr($legacy_id, 34);
         $test = 'test';
         $classroom->legacy_id = (string) $legacy_id;
         $classroom->skrot = (string) $salax[1];
         $classroom->pelna_nazwa = (string) '';
         $id = R::store($classroom);
     }
 }
コード例 #7
0
 public static function deleteAll()
 {
     Database::setup();
     $userBean = R::dispense(Model_User::$table_name);
     R::wipe($userBean);
 }
コード例 #8
0
ファイル: AMFUtil.php プロジェクト: limweb/webappservice
 public static function clearsystemlog($userid)
 {
     if (self::if_table_exists('systemlog')) {
         $rs = R::wipe('systemlog');
         return $rs;
     } else {
         self::createSystemlog();
         return 0;
     }
 }
コード例 #9
0
 public function DeleteAllCompanyStatus()
 {
     R::wipe('companystatus');
 }
コード例 #10
0
ファイル: ltest.php プロジェクト: ryjkov/redbean
R::$writer->setBeanFormatter($tf);
testViews("prefix_");
$tf2 = new Fm2();
R::$writer->setBeanFormatter($tf2);
testViews("prefix_");
testpack("wipe and constraints");
R::exec(" drop table if exists page ");
R::exec(" drop table if exists book ");
R::exec(" drop table if exists book_page ");
R::exec(" drop table if exists prefix_page ");
R::exec(" drop table if exists prefix_book ");
R::exec(" drop table if exists prefix_book_page ");
R::exec("DROP TRIGGER IF EXISTS fkc2d4c7ea9e656a361bc08c9d072914cca ");
R::exec("DROP TRIGGER IF EXISTS fkc2d4c7ea9e656a361bc08c9d072914ccb ");
$page1 = R::dispense("page");
$book1 = R::dispense("book");
$page2 = R::dispense("page");
$book2 = R::dispense("book");
$page1->name = "page1";
$page2->name = "page2";
$book1->name = "book1";
$book2->name = "book2";
R::associate($book1, $page1);
R::associate($book2, $page2);
//exit;
asrt(count(R::getAll("select * from prefix_book_page")), 2);
R::trash($book1);
asrt(count(R::getAll("select * from prefix_book_page")), 1);
R::wipe("book");
asrt(count(R::getAll("select * from prefix_book_page")), 0);
printtext("\nALL TESTS PASSED. REDBEAN SHOULD WORK FINE.\n");
コード例 #11
0
ファイル: test.php プロジェクト: ryjkov/redbean
asrt(setget("null"), "null");
asrt(setget("NULL"), "NULL");
asrt(setget("0123", 1), "0123");
asrt(setget("0000123", 1), "0000123");
asrt(setget(null), null);
asrt(setget(0) == 0, true);
asrt(setget(1) == 1, true);
asrt(setget(true) == true, true);
asrt(setget(false) == false, true);
testpack("fetch tagged items");
R::exec("drop table author_book");
R::exec("drop table author");
R::exec("drop table book");
R::wipe("book");
R::wipe("tag");
R::wipe("book_tag");
$b = R::dispense("book");
$b->title = 'horror';
R::store($b);
$c = R::dispense("book");
$c->title = 'creepy';
R::store($c);
$d = R::dispense("book");
$d->title = "chicklit";
R::store($d);
R::tag($b, "horror,classic");
R::tag($d, "women,classic");
R::tag($c, "horror");
$x = R::tagged("book", "classic");
asrt(count($x), 2);
$x = R::tagged("book", "classic,horror");
コード例 #12
0
 /**
  * Test Transactions.
  * 
  * @return void
  */
 public function testTransactions()
 {
     testpack('transactions');
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::commit();
     asrt(R::count('bean'), 1);
     R::wipe('bean');
     R::freeze(1);
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::rollback();
     asrt(R::count('bean'), 0);
     R::freeze(FALSE);
     testpack('genSlots');
     asrt(R::genSlots(array('a', 'b')), '?,?');
     asrt(R::genSlots(array('a')), '?');
     asrt(R::genSlots(array()), '');
 }
コード例 #13
0
ファイル: DemoController.php プロジェクト: youprofit/Zurmo
 protected function createImportTempTable($columnCount, $tableName)
 {
     $freezeWhenComplete = false;
     if (RedBeanDatabase::isFrozen()) {
         RedBeanDatabase::unfreeze();
         $freezeWhenComplete = true;
     }
     $newBean = R::dispense($tableName);
     for ($i = 0; $i < $columnCount; $i++) {
         $columnName = 'column_' . $i;
         $newBean->{$columnName} = str_repeat(' ', 50);
         $columns[] = $columnName;
     }
     R::store($newBean);
     R::trash($newBean);
     R::wipe($tableName);
     ImportDatabaseUtil::optimizeTableNonImportColumns($tableName);
     R::wipe($tableName);
     if ($freezeWhenComplete) {
         RedBeanDatabase::freeze();
     }
 }
コード例 #14
0
ファイル: pgtest.php プロジェクト: ryjkov/redbean
 R::associate($painter, $painter);
 asrt(getList(R::unrelated($accountant, "person"), "job"), "");
 asrt(getList(R::unrelated($painter, "person"), "job"), "developer,salesman");
 asrt(getList(R::unrelated($salesman, "person"), "job"), "painter");
 asrt(getList(R::unrelated($developer, "person"), "job"), "painter");
 testpack("Test count and wipe");
 $page = R::dispense("page");
 $page->name = "ABC";
 R::store($page);
 $n1 = R::count("page");
 $page = R::dispense("page");
 $page->name = "DEF";
 R::store($page);
 $n2 = R::count("page");
 asrt($n1 + 1, $n2);
 R::wipe("page");
 asrt(R::count("page"), 0);
 asrt(R::$redbean->count("page"), 0);
 function setget($val)
 {
     global $pdo;
     $bean = R::dispense("page");
     $_tables = R::$writer->getTables();
     if (in_array("page", $_tables)) {
         $pdo->Execute("DROP TABLE page");
     }
     $bean->prop = $val;
     $id = R::store($bean);
     $bean = R::load("page", $id);
     asrt(is_string($bean->prop) || is_null($bean->prop), true);
     return $bean->prop;
コード例 #15
0
ファイル: ManagerTraits.php プロジェクト: dongww/simple-db
 public function wipe()
 {
     \R::wipe($this->getTableName());
 }
コード例 #16
0
 protected static function optimizeTableImportColumnsAndGetColumnNames($fileHandle, $tableName, $delimiter, $enclosure)
 {
     assert('gettype($fileHandle) == "resource"');
     assert('is_string($tableName)');
     assert('$tableName == strtolower($tableName)');
     assert('$delimiter != null && is_string($delimiter)');
     assert('$enclosure != null && is_string($enclosure)');
     $maxValues = array();
     $columns = array();
     while (($data = fgetcsv($fileHandle, 0, $delimiter, $enclosure)) !== false) {
         if (count($data) > 1 || count($data) == 1 && trim($data['0']) != '') {
             foreach ($data as $k => $v) {
                 if (!isset($maxValues[$k]) || strlen($maxValues[$k]) < strlen($v)) {
                     $maxValues[$k] = $v;
                 }
             }
         }
     }
     if (count($maxValues) > 0) {
         $newBean = R::dispense($tableName);
         foreach ($maxValues as $columnId => $value) {
             $columnName = 'column_' . $columnId;
             $newBean->{$columnName} = str_repeat(' ', strlen($value));
             $columns[] = $columnName;
         }
         R::store($newBean);
         R::trash($newBean);
         R::wipe($tableName);
     }
     return $columns;
 }
コード例 #17
0
ファイル: index.php プロジェクト: exiang/beginning-arduino
                    echo "<p>Fail to register '{$code}'. Pls try another code.</p>";
                }
            } else {
                echo "<p>Fail to register '{$code}'. Pls try another code.</p>";
            }
        } else {
            echo "<p>Code cannot be empty</p>";
        }
    } else {
        echo '<form action="index.php?c=register&d=process" method="post" >';
        echo '<input type="text" value="" name="code" />';
        echo '<input type="submit" value="Register" />';
        echo '</form>';
    }
} else {
    if ($c == 'list') {
        echo "<p>Listing all registered account:</p>";
        $ws = R::findAll('workshop');
        foreach ($ws as $w) {
            echo "<p>{$w->code}: R[{$w->red}] G[{$w->green}] B[{$w->blue}]</p>";
        }
    } else {
        if ($c == 'reset') {
            echo "<p>Reset all data</p>";
            R::wipe('workshop');
            echo "<p>DONE</p>";
        } else {
            echo "<p>Invalid request</p>";
        }
    }
}