当前位置: 首页>>代码示例>>PHP>>正文


PHP R::load方法代码示例

本文整理汇总了PHP中R::load方法的典型用法代码示例。如果您正苦于以下问题:PHP R::load方法的具体用法?PHP R::load怎么用?PHP R::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete_event

function delete_event($id)
{
    $event = R::load('events', $id);
    //reloads our event
    R::trash($event);
    //for one bean
}
开发者ID:sousatg,项目名称:events-backoffice,代码行数:7,代码来源:events.php

示例2: testTainted

 /**
  * 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');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:40,代码来源:Tainted.php

示例3: delete_news

function delete_news($id)
{
    $news = R::load('news', $id);
    //reloads our event
    R::trash($news);
    //for one bean
}
开发者ID:sousatg,项目名称:events-backoffice,代码行数:7,代码来源:news.php

示例4: init

 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;
         }
     }
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:26,代码来源:Controller_GameAuth.class.php

示例5: edit_post

 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());
 }
开发者ID:neyre,项目名称:tools.olin.edu,代码行数:30,代码来源:tools.php

示例6: handle

 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';
 }
开发者ID:Raffprta,项目名称:Open-Access,代码行数:30,代码来源:editpub.php

示例7: testBasicNullHandling

 /**
  * 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();
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:36,代码来源:Null.php

示例8: playlist

function playlist()
{
    $playlist = R::load('playlists', 1);
    foreach ($playlist->sharedSongsList as $key => $song) {
        echo "\n\n\t iterating:\t: " . $song->title . "\n";
    }
}
开发者ID:alexanderankin,项目名称:wbackend,代码行数:7,代码来源:databaseMisc.php

示例9: deleteFromList

 public function deleteFromList($id)
 {
     $ban = R::load('banlist', $id);
     $value = $ban->value;
     R::trash($ban);
     return $value;
 }
开发者ID:zeamxie,项目名称:jobskee-open-source-job-board,代码行数:7,代码来源:Banlist.php

示例10: view

 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();
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:29,代码来源:admin.php

示例11: testTags

 /**
  * 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");
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:65,代码来源:Tags.php

示例12: testRebuilder

 /**
  * 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);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:36,代码来源:Rebuild.php

示例13: testTypes

 /**
  * 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');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:62,代码来源:Typechecking.php

示例14: restore

 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);
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:30,代码来源:admin.php

示例15: saveControle

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;
}
开发者ID:leloulight,项目名称:didapi,代码行数:26,代码来源:save_controle.php


注:本文中的R::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。