Example #1
0
function delete_event($id)
{
    $event = R::load('events', $id);
    //reloads our event
    R::trash($event);
    //for one bean
}
 /**
  * Test tainted.
  * 
  * @return void
  */
 public function testTainted()
 {
     testpack('Original Tainted Tests');
     $redbean = R::$redbean;
     $spoon = $redbean->dispense("spoon");
     asrt($spoon->getMeta("tainted"), TRUE);
     $spoon->dirty = "yes";
     asrt($spoon->getMeta("tainted"), TRUE);
     testpack('Tainted List test');
     $note = R::dispense('note');
     $note->text = 'abc';
     $note->ownNote[] = R::dispense('note')->setAttr('text', 'def');
     $id = R::store($note);
     $note = R::load('note', $id);
     asrt($note->isTainted(), FALSE);
     // Shouldn't affect tainted
     $note->text;
     asrt($note->isTainted(), FALSE);
     $note->ownNote;
     asrt($note->isTainted(), TRUE);
     testpack('Tainted Test Old Value');
     $text = $note->old('text');
     asrt($text, 'abc');
     asrt($note->hasChanged('text'), FALSE);
     $note->text = 'xxx';
     asrt($note->hasChanged('text'), TRUE);
     $text = $note->old('text');
     asrt($text, 'abc');
     testpack('Tainted Non-exist');
     asrt($note->hasChanged('text2'), FALSE);
     testpack('Misc Tainted Tests');
     $bean = R::dispense('bean');
     $bean->hasChanged('prop');
     $bean->old('prop');
 }
Example #3
0
function delete_news($id)
{
    $news = R::load('news', $id);
    //reloads our event
    R::trash($news);
    //for one bean
}
 public function init()
 {
     // check if logged in session is valid, if not redir to main page
     if (!isset($_SESSION['loginHash'])) {
         Framework::Redir("site/index");
         die;
     }
     $activeSession = R::findOne('session', ' hash = ? AND ip = ? AND expires > ?', array($_SESSION['loginHash'], $_SERVER['REMOTE_ADDR'], time()));
     if (!$activeSession) {
         unset($_SESSION['loginHash']);
         Framework::Redir("site/index/main/session_expired");
         die;
     }
     $activeSession->expires = time() + SESSION_MAX_AGE * 2;
     R::store($activeSession);
     $this->session = $activeSession;
     $this->user = R::load('user', $this->session->user->getId());
     Framework::TPL()->assign('user_premium', $this->user->hasPremium());
     // check needed rights if any
     foreach ($this->_rights as $r) {
         if (!$this->user->hasRight($r)) {
             Framework::Redir("game/index");
             die;
         }
     }
 }
Example #5
0
 function edit_post($f3)
 {
     // Update Tool Locations
     $this->D->sharedLocationsList = array();
     if ($f3->exists('POST.locations')) {
         foreach ($f3->get('POST.locations') as $id) {
             $this->D->sharedLocationsList[] = \R::load('locations', $id);
         }
     }
     $f3->clear('POST.locations');
     $this->D->import($f3->get('POST'));
     $this->D->training_levels or $this->D->training_levels = json_encode($f3->get('TRAINING_LEVELS'));
     \R::begin();
     try {
         $id = \R::store($this->D);
         \R::commit();
     } catch (\Exception $e) {
         \R::rollback();
         if ($e->getSQLState() == 23000) {
         }
         throw new \Exception($this->D->name . ' is not a unique name.');
         throw new \Exception();
     }
     if ($f3->get('dry')) {
         logger($f3, 'added    ' . $this->class_name() . ', id=' . $id);
     } else {
         logger($f3, 'modified ' . $this->class_name() . ', id=' . $id);
     }
     $f3->reroute($this->redirect());
 }
Example #6
0
 public function handle($context)
 {
     # Ensure that the user is staff at least
     $context->mustbestaff();
     # Load the publication RESTfully
     $pub = R::load('publication', $context->rest()[0]);
     # Check if the staff is allowed to edit it.
     if ($context->user()->id != $pub->uploaderId) {
         $context->local()->addval('error', 'You must be the staff who uploaded this to edit it.');
         return 'editpub.twig';
     }
     # Check if it's a post
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         # Set up a new publication handler.
         $pubcreator = new Manipulatepub($pub, 'editpub.twig');
         $returnerr = $pubcreator->manipulatepublication($context);
         # If it's a non-empty string a error occured.
         if (!empty($returnerr)) {
             $context->local()->addval('error', $returnerr);
             return 'editpub.twig';
         }
         $pub = $pubcreator->getpub();
         # Otherwise it is a publication, so store it.
         R::store($pub);
         # The publication has been sucessfully edited, let's divert the user to the view page using REST.
         $context->divert("/viewpub/" . $pub->id);
     }
     $context->local()->addval(['pub' => $pub, 'auths' => $pub->sharedAuthor]);
     return 'editpub.twig';
 }
Example #7
0
 /**
  * Test NULL handling, setting a property to NULL must
  * cause a change.
  * 
  * @return void
  */
 public function testBasicNullHandling()
 {
     // NULL can change bean
     $bean = R::dispense('bean');
     $bean->bla = 'a';
     R::store($bean);
     $bean = $bean->fresh();
     asrt($bean->hasChanged('bla'), FALSE);
     $bean->bla = NULL;
     asrt($bean->hasChanged('bla'), TRUE);
     // NULL test
     $page = R::dispense('page');
     $book = R::dispense('book');
     $page->title = 'a NULL page';
     $page->book = $book;
     $book->title = 'Why NUll is painful..';
     R::store($page);
     $bookid = $page->book->id;
     unset($page->book);
     $id = R::store($page);
     $page = R::load('page', $id);
     $page->title = 'another title';
     R::store($page);
     pass();
     $page = R::load('page', $id);
     $page->title = 'another title';
     $page->book_id = NULL;
     R::store($page);
     pass();
 }
Example #8
0
function playlist()
{
    $playlist = R::load('playlists', 1);
    foreach ($playlist->sharedSongsList as $key => $song) {
        echo "\n\n\t iterating:\t: " . $song->title . "\n";
    }
}
 public function deleteFromList($id)
 {
     $ban = R::load('banlist', $id);
     $value = $ban->value;
     R::trash($ban);
     return $value;
 }
Example #10
0
 function view($args)
 {
     $id = array_shift($args);
     $permission = R::load('permission', $id);
     if (!is_numeric($id) && !$permission->getID()) {
         $this->redirect(PACKAGE_URL);
     }
     $allgroups = R::findAll('group');
     foreach ($allgroups as $key => $group) {
         foreach ($permission->sharedGroup as $group_c) {
             if ($group->id == $group_c->id) {
                 $allgroups[$key]->checked = true;
             }
         }
     }
     //		echo $permission->name;exit;
     $view = new G2_TwigView('pages/view');
     $view->permission = $permission;
     $view->allGroups = $allgroups;
     $form = new G2_FormMagic($view->get_render());
     if ($form->is_posted()) {
         $groups = R::loadAll('group', array_keys($form->data()['groups']));
         $permission->sharedGroup = $groups;
         R::store($permission);
         Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
         $this->redirect(PACKAGE_URL);
     }
     echo $form->parse();
 }
Example #11
0
 /**
  * Some basic tests.
  * 
  * @return void
  */
 public function testTags()
 {
     list($c, $d, $e, $f) = R::dispense('coffee', 4);
     R::tag($c, 'strong,black');
     R::tag($d, 'black');
     R::tag($e, 'strong,sweet');
     R::tag($f, 'black,strong');
     //$x = array_intersect(R::tagged('coffee','sweet'),R::tagged('coffee','strong'));
     asrt(count(R::taggedAll('coffee', 'strong,sweet')), 1);
     asrt(count(R::taggedAll('coffee', 'strong')), 3);
     asrt(count(R::taggedAll('coffee', '')), 0);
     asrt(count(R::taggedAll('coffee', 'sweet')), 1);
     asrt(count(R::taggedAll('coffee', 'sweet,strong')), 1);
     asrt(count(R::taggedAll('coffee', 'black,strong')), 2);
     asrt(count(R::taggedAll('coffee', array('black', 'strong'))), 2);
     asrt(count(R::taggedAll('coffee', 'salty')), 0);
     $blog = R::dispense('blog');
     $blog->title = 'testing';
     $blog->blog = 'tesing';
     R::store($blog);
     $blogpost = R::load("blog", 1);
     $post = R::dispense("post");
     $post->message = "hello";
     R::tag($post, "lousy,smart");
     asrt(implode(',', R::tag($post)), "lousy,smart");
     R::tag($post, "clever,smart");
     $tagz = implode(',', R::tag($post));
     asrt($tagz == "smart,clever" || $tagz == "clever,smart", TRUE);
     R::tag($blog, array("smart", "interesting"));
     asrt(implode(',', R::tag($blog)), "smart,interesting");
     try {
         R::tag($blog, array("smart", "interesting", "lousy!"));
         pass();
     } catch (RedBean_Exception $e) {
         fail();
     }
     asrt(implode(',', R::tag($blog)), "smart,interesting,lousy!");
     R::untag($blog, array("smart", "interesting"));
     asrt(implode(",", R::tag($blog)), "lousy!");
     asrt(R::hasTag($blog, array("lousy!")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart")), TRUE);
     asrt(R::hasTag($blog, array("lousy!", "smart"), TRUE), FALSE);
     R::tag($blog, FALSE);
     asrt(count(R::tag($blog)), 0);
     R::tag($blog, array("funny", "comic"));
     asrt(count(R::tag($blog)), 2);
     R::addTags($blog, array("halloween"));
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("funny", "commic", "halloween"), TRUE), FALSE);
     R::unTag($blog, "funny");
     R::addTags($blog, "horror");
     asrt(count(R::tag($blog)), 3);
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     //no double tags
     R::addTags($blog, "horror");
     asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
     asrt(R::hasTag($blog, "horror,commic,halloween", TRUE), FALSE);
     asrt(count(R::tag($blog)), 3);
     testpack("fetch tagged items");
 }
Example #12
0
 /**
  * Test SQLite table rebuilding.
  * 
  * @return void
  */
 public function testRebuilder()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     R::dependencies(array('page' => array('book')));
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     $book->added = 2;
     R::store($book);
     $book->added = 'added';
     R::store($book);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
 }
 /**
  * Test types.
  * Test how RedBeanPHP OODB and OODBBean handle type and type casts.
  * 
  * Rules:
  * 
  * 1. before storing a bean all types are preserved except booleans (they are converted to STRINGS '0' or '1')
  * 2. after store-reload all bean property values are STRINGS or NULL 
  *    (or ARRAYS but that's only from a user perspective because these are lazy loaded)
  * 3. the ID returned by store() is an INTEGER (if possible; on 32 bit systems overflowing values will be cast to STRINGS!)
  * 
  * After loading:
  * ALL VALUES EXCEPT NULL -> STRING
  * NULL -> NULL
  * 
  * @note Why not simply return bean->id in store()? Because not every driver returns the same type:
  * databases without insert_id support require a separate query or a suffix returning STRINGS, not INTEGERS.
  * 
  * @note Why not preserve types? I.e. I store integer, why do I get back a string?
  * Answer: types are handled different across database platforms, would cause overhead to inspect every value for type,
  * also PHP is a dynamically typed language so types should not matter that much. Another reason: due to the nature
  * of RB columns in the database might change (INT -> STRING) this would cause return types to change as well which would
  * cause 'cascading errors', i.e. a column gets widened and suddenly your code would break.
  * 
  * @note Unfortunately the 32/64-bit issue cannot be tested fully. Return-strategy store() is probably the safest
  * solution.
  * 
  * @return void
  */
 public function testTypes()
 {
     testpack('Beans can only contain STRING and NULL after reload');
     R::nuke();
     $bean = R::dispense('bean');
     $bean->number = 123;
     $bean->float = 12.3;
     $bean->bool = false;
     $bean->bool2 = true;
     $bean->text = 'abc';
     $bean->null = null;
     $bean->datetime = new DateTime('NOW', new DateTimeZone('Europe/Amsterdam'));
     $id = R::store($bean);
     asrt(is_int($id), TRUE);
     asrt(is_float($bean->float), TRUE);
     asrt(is_integer($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     $bean = R::load('bean', $id);
     asrt(is_string($bean->id), TRUE);
     asrt(is_string($bean->float), TRUE);
     asrt(is_string($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     asrt($bean->bool, '0');
     asrt($bean->bool2, '1');
 }
Example #14
0
 function restore($args)
 {
     $what = array_shift($args);
     $id = array_shift($args);
     if (!is_numeric($id) || !($audit = R::load('audit', $id))) {
         $this->redirect(PACKAGE_URL);
     }
     $audit = current(Audit::deserialize([$audit]));
     if ($what == 'new') {
         $bean = $audit->new_obj;
     } else {
         $bean = $audit->old_obj;
     }
     //Retrieve the current record
     $current = R::findOne($bean->getMeta('type'), 'id = :id', array('id' => $bean->id));
     if (!$current) {
         // Record was removed. Thus record needs to be recreated
         //$bean = R::dup($bean);
     }
     $old = $current != null ? clone $current : null;
     if ($current == null) {
         $current = R::dispense($bean->getMeta('type'));
     }
     foreach ($bean as $field => $value) {
         $current->{$field} = $value;
     }
     R::store($current);
     Audit::create($old, $current, "restored to previous version changed on {$audit->date_logged}");
     $this->redirect(PACKAGE_URL);
 }
Example #15
0
function saveControle($data)
{
    $success = false;
    R::setup('mysql:host=' . Database::HOST . ';dbname=' . Database::NAME, Database::USERNAME, Database::PASSWORD);
    $controle = R::dispense('controle');
    $controle->date = $data['date'];
    $controle->traitement = $data['traitement'] == "true" ? 1 : 0;
    if ($controle->traitement) {
        $controle->traitement_type = $data['traitement_type'];
    }
    $controle->nourrissement = $data['nourrissement'] == "true" ? 1 : 0;
    if ($controle->nourrissement) {
        $controle->nourrissement_quantite = $data['nourrissement_quantite'];
    }
    $controle->nombre_cadres_couvains = $data['nombre_cadres_couvains'];
    $controle_id = R::store($controle);
    $ruche = R::load('ruche', $data['ruche_id']);
    if ($ruche->id) {
        $ruche->ownControle[] = $controle;
        $saved_ruche_id = R::store($ruche);
        if (isset($controle_id) && isset($saved_ruche_id)) {
            $success = true;
        }
    }
    return $success;
}
Example #16
0
 function update_field($id, $field, $value)
 {
     $client = R::load('client', $id);
     $client->{$field} = $value;
     R::store($client);
     return $id;
 }
Example #17
0
 /**
  * Various.
  * Various test for OCI. Some basic test cannot be performed because
  * practical issues (configuration testing VM image etc..).
  * 
  * @return void
  */
 public function testOCIVaria()
 {
     $village = R::dispense('village');
     $village->name = 'Lutry';
     $id = R::store($village);
     $village = R::load('village', $id);
     asrt($village->name, 'Lutry');
     list($mill, $tavern) = R::dispense('building', 2);
     $village->ownBuilding = array($mill, $tavern);
     //replaces entire list
     $id = R::store($village);
     asrt($id, 1);
     $village = R::load('village', $id);
     asrt(count($village->ownBuilding), 2);
     $village2 = R::dispense('village');
     $army = R::dispense('army');
     $village->sharedArmy[] = $army;
     $village2->sharedArmy[] = $army;
     R::store($village);
     $id = R::store($village2);
     $village = R::load('village', $id);
     $army = $village->sharedArmy;
     $myVillages = R::related($army, 'village');
     asrt(count($myVillages), 2);
     echo PHP_EOL;
 }
 function updatePos($idcliente, $data)
 {
     foreach ($data as $key => $value) {
         $menu = R::load('menu', $value);
         $menu->pos = $key;
         R::store($menu);
     }
 }
Example #19
0
 public function init($name, $id = false)
 {
     $this->table_name = $name;
     if ($id) {
         $this->bean = R::load($name, $id);
     } else {
         $this->bean = R::dispense($name);
     }
 }
 /**
  * Function to send notification when users changes the participation changes
  * @param int  $eventId id of event which is added
  * @param \RedBeanPHP\OODBBean $participantDetails Details of user who is participating
  * @return void
  * **/
 public function participationNotifications($eventId, $participantDetails)
 {
     $eventDetails = \R::load('events', $eventId);
     $eventOwnerDetails = \R::load('users', $eventDetails->users_id);
     $deviceType = $eventOwnerDetails->device_type;
     $deviceToken = $eventOwnerDetails->device_token;
     $message = "{$participantDetails->first_name} is coming to event {$eventDetails->event_name}";
     $this->send_notification($message, array($deviceToken), $deviceType);
 }
Example #21
0
 public function delete_page($args)
 {
     $page_id = array_shift($args);
     if ($page = R::load('page', $page_id)) {
         $old = clone $page;
         R::trash($page);
         Audit::create($old, NULL, 'Developer deleted page from system');
     }
     $this->redirect(PACKAGE_URL);
 }
 public function deleteCity()
 {
     $count = R::count('jobs', " city=:city ", array(':city' => $this->_id));
     if (!$count) {
         $city = R::load('cities', $this->_id);
         R::trash($city);
         return true;
     }
     return false;
 }
 public static function getBean(RedBean_OODBBean $bean, $typeName, $name = null)
 {
     $fieldName = self::getLinkField($typeName, $name);
     $id = (int) $bean->{$fieldName};
     if ($id) {
         return R::load($typeName, $id);
     } else {
         return null;
     }
 }
Example #24
0
 /**
  * Test UTF8 handling.
  * 
  * @return void
  */
 public function testUTF8()
 {
     $str = '𠜎ὃ𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜';
     $bean = R::dispense('bean');
     $bean->bla = $str;
     R::store($bean);
     $bean = R::load('bean', $bean->id);
     asrt($bean->bla, $str);
     pass();
 }
 public function deleteCategory()
 {
     $count = R::count('jobs', " category=:category ", array(':category' => $this->_id));
     if (!$count) {
         $category = R::load('categories', $this->_id);
         R::trash($category);
         return true;
     }
     return false;
 }
Example #26
0
 public function show_Inventory()
 {
     $items = R::find('inventory', ' user_id = ?', array($this->user->getID()));
     $i = array();
     foreach ($items as $itm) {
         $item = R::load('inventory', $itm->getID());
         $i[] = array("id" => $item->getID(), "name" => $item->item->name, "desc" => str_replace('{param}', $item->param, $item->item->desc), "is_usable" => $item->item->usable == 1 ? true : false, "value" => $item->item->value, "usable_link" => $item->item->usable_link_desc, "amount" => $item->amount, "type" => $item->item->type);
     }
     $this->output('items', $i);
 }
Example #27
0
 /**
  * Return data files as requested
  *
  * @param object	$context	The context object for the site
  * @param object	$local		The local object for the site
  *
  * @return string	A template name
  */
 public function handle($context)
 {
     $web = Web::getinstance();
     # it's used all over the place so grab it once
     chdir($context->local()->basedir());
     $fpt = $context->rest();
     if (count($fpt) == 2 && $fpt[0] == 'file') {
         # this is access by upload ID
         $file = R::load('upload', $fpt[1]);
         if ($file->getID() == 0) {
             $web->notfound();
             /* NOT REACHED */
         }
         $this->file = substr($file->fname, 1);
         // drop the separator at the start....
     } else {
         chdir(self::DATADIR);
         /**
          * Depending on how you construct the URL, it's possible to do some sanity checks on the
          * values passed in. The structure assumed here is /user_id/year/month/filename so
          * the regexp test following makes sense.
          * This all depends on your application and how you want to treat files and filenames and access of course!
          *
          * ALways be careful that filenames do not have .. in them of course.
          * 
          */
         $this->file = implode(DIRECTORY_SEPARATOR, $fpt);
         if (!preg_match('#^[0-9]+/[0-9]+/[0-9]+/[^/]+$#', implode('/', $fpt))) {
             # filename constructed is not the right format
             $web->bad();
             /* NOT REACHED */
         }
         # Now do an access control check
         $file = R::findOne('upload', 'fname=?', [DIRECTORY_SEPARATOR . self::DATADIR . DIRECTORY_SEPARATOR . $this->file]);
         if (!is_object($file)) {
             # not recorded in the database so 404 it
             $web->notfound();
             /* NOT REACHED */
         }
     }
     if (!$file->canaccess($context->user())) {
         # caurrent user cannot access the file
         $web->noaccess();
         /* NOT REACHED */
     }
     if (($this->mtime = filemtime($this->file)) === FALSE) {
         $web->internal('Lost File: ' . $this->file);
         /* NOT REACHED */
     }
     $this->ifmodcheck();
     # check to see if we actually need to send anything
     $web->addheader(['Last-Modified' => $this->mtime, 'Etag' => '"' . $this->makeetag() . '"']);
     $web->sendfile($this->file, $file->filename);
     return '';
 }
Example #28
0
 public static function update($id, $title, $body)
 {
     $bean = R::load('post', $id);
     $bean->title = $title;
     $bean->body = $body;
     if (R::store($bean)) {
         return true;
     } else {
         return false;
     }
 }
Example #29
0
 public function select($id = null)
 {
     // no id and no other params
     if ($id == null) {
         $items = R::loadAll($this->table, array());
         return $items;
     } else {
         $item = R::load($this->table, $id);
         return $item;
     }
 }
 /**
  * Various tests for OCI.
  * 
  * @return void
  */
 public function testVaria()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     try {
         $adapter->exec("an invalid query");
         fail();
     } catch (RedBean_Exception_SQL $e) {
         pass();
     }
     asrt((int) $adapter->getCell("SELECT 123 FROM DUAL"), 123);
     $page->aname = "my page";
     $id = (int) $redbean->store($page);
     asrt((int) $page->id, 1);
     asrt((int) $pdo->GetCell("SELECT count(*) FROM page"), 1);
     asrt($pdo->GetCell("SELECT aname FROM page WHERE ROWNUM<=1"), "my page");
     asrt((int) $id, 1);
     $page = $redbean->load("page", 1);
     asrt($page->aname, "my page");
     asrt((bool) $page->getMeta("type"), TRUE);
     asrt(isset($page->id), TRUE);
     asrt($page->getMeta("type"), "page");
     asrt((int) $page->id, $id);
     R::nuke();
     $rooms = R::dispense('room', 2);
     $rooms[0]->kind = 'suite';
     $rooms[1]->kind = 'classic';
     $rooms[0]->number = 6;
     $rooms[1]->number = 7;
     R::store($rooms[0]);
     R::store($rooms[1]);
     $rooms = R::getAssoc('SELECT ' . R::$writer->esc('number') . ', kind FROM room ORDER BY kind ASC');
     foreach ($rooms as $key => $room) {
         asrt($key === 6 || $key === 7, TRUE);
         asrt($room == 'classic' || $room == 'suite', TRUE);
     }
     $rooms = R::$adapter->getAssoc('SELECT kind FROM room');
     foreach ($rooms as $key => $room) {
         asrt($room == 'classic' || $room == 'suite', TRUE);
         asrt($room, $key);
     }
     $rooms = R::getAssoc('SELECT ' . R::$writer->esc('number') . ', kind FROM rooms2 ORDER BY kind ASC');
     asrt(count($rooms), 0);
     asrt(is_array($rooms), TRUE);
     $date = R::dispense('mydate');
     $date->date = '2012-12-12 20:50';
     $date->time = '12:15';
     $id = R::store($date);
     $ok = R::load('mydate', 1);
 }