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


PHP R::unassociate方法代码示例

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


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

示例1: removeRight

 /**
  * remove right from user
  * @param string $type
  * @return boolean
  */
 public function removeRight($type)
 {
     $right = RCached::findOne('user_right', ' type = ?', array($type), date("d.m.Y"));
     if (!$right) {
         return false;
     }
     R::unassociate($this->bean, $right);
     return true;
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:14,代码来源:Model_User.class.php

示例2: unsubscribe

 /**
     User removes himself from a mailing list
 */
 public static function unsubscribe()
 {
     $user = self::getUser();
     if (!$user) {
         return RedView::set('error', "You're not on any of our lists.");
     }
     if (!($list = self::getList())) {
         return RedView::set('error', "List doesn't exist.");
     }
     R::unassociate($list, $user);
 }
开发者ID:paulk12,项目名称:redskeleton,代码行数:14,代码来源:subscribe.php

示例3: showdown

 public function showdown()
 {
     $allPlayers = R::related($this->bean, 'poker_player');
     $pokerHands = array(10 => new PokerParser("[a>a>a>a>a"), 9 => new PokerParser("a>a>a>a>a"), 8 => new PokerParser("1{4}"), 7 => new PokerParser("1{3}2{2}"), 6 => new PokerParser("a{5}"), 5 => new PokerParser("?>?>?>?>?"), 4 => new PokerParser("1{3}"), 3 => new PokerParser("1{2}2{2}"), 2 => new PokerParser("1{2}"), 1 => new PokerParser("?"));
     $bestValue = -1;
     $winners = array();
     $totalPot = $this->bean->global_pot;
     // new round to move players to
     $nextRound = R::findOne('poker_round', " state='pending'");
     if ($nextRound == null) {
         $nextRound = R::dispense('poker_round');
         $nextRound->state = 'pending';
         $nextRound->step = 0;
         $nextRound->global_pot = 0;
         R::store($nextRound);
     }
     foreach ($allPlayers as $p) {
         $cards = array_merge(json_decode($p->cards, true), json_decode($this->bean->cards, true));
         $totalPot += $p->bid;
         $val = 0;
         foreach ($pokerHands as $value => $parser) {
             if ($parser->check($cards)) {
                 // player has this
                 $val = $value * 100 + $parser->getHighestCardValue();
                 break;
             }
         }
         if ($val > $bestValue) {
             $bestValue = $val;
             $winners = array($p);
         } elseif ($val == $bestValue) {
             $winners[] = $p;
         }
         // kick from current round
         R::unassociate($this->bean, $p);
         // put into next round
         R::associate($nextRound, $p);
     }
     $winnerCount = count($winners);
     $winAmount = floor($totalPot / $winnerCount);
     $winnerNames = array();
     foreach ($winners as $win) {
         $usr = R::relatedOne($win, 'user');
         $usr->cash += $winAmount;
         $winnerNames[] = $usr->username;
         R::store($usr);
     }
     R::trash($this->bean);
     return array("winners" => $winnerNames, "amount" => $winAmount, "bestValue" => $bestValue);
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:50,代码来源:Model_Poker_round.class.php

示例4: testMultiAssociationDissociation

 /**
  * Test multiple assiociation.
  * 
  * @return void
  */
 public function testMultiAssociationDissociation()
 {
     $wines = R::dispense('wine', 3);
     $cheese = R::dispense('cheese', 3);
     $olives = R::dispense('olive', 3);
     R::associate($wines, array_merge($cheese, $olives));
     asrt(R::count('cheese'), 3);
     asrt(R::count('olive'), 3);
     asrt(R::count('wine'), 3);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 3);
     asrt(count($wines[1]->sharedCheese), 3);
     asrt(count($wines[1]->sharedOlive), 3);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 3);
     R::unassociate($wines, $olives);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 3);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 0);
     R::unassociate(array($wines[1]), $cheese);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 0);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 3);
     asrt(count($wines[2]->sharedOlive), 0);
     R::unassociate(array($wines[2]), $cheese);
     asrt(count($wines[0]->sharedCheese), 3);
     asrt(count($wines[0]->sharedOlive), 0);
     asrt(count($wines[1]->sharedCheese), 0);
     asrt(count($wines[1]->sharedOlive), 0);
     asrt(count($wines[2]->sharedCheese), 0);
     asrt(count($wines[2]->sharedOlive), 0);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:42,代码来源:Association.php

示例5: untag

 public static function untag($bean, $tagList)
 {
     if ($tagList !== false && !is_array($tagList)) {
         $tags = explode(",", (string) $tagList);
     } else {
         $tags = $tagList;
     }
     foreach ($tags as $tag) {
         $t = R::findOne("tag", " title = ? ", array($tag));
         if ($t) {
             R::unassociate($bean, $t);
         }
     }
 }
开发者ID:bobseven,项目名称:Slim-Blog,代码行数:14,代码来源:rb.php

示例6: cmp_ip

/**
 * 
 */
function cmp_ip($serverIP, RedBean_OODBBean $domain)
{
    if (strpos($domain->name, '*') !== false) {
        throw new Exception('Domain name contains *');
    }
    if ($dnsRecords = dns_get_record($domain->name)) {
        $error = true;
        $registeredIPs = array();
        $related = R::related($domain, 'ip_address');
        if (!empty($related)) {
            foreach ($related as $rel) {
                $registeredIPs[$rel->value] = $rel;
            }
        }
        $updateTimestamp = mktime();
        foreach ($dnsRecords as $record) {
            if (!isset($record['type']) || !in_array($record['type'], array('A', 'NS'))) {
                continue;
            }
            switch ($record['type']) {
                case 'A':
                    $value = $record['ip'];
                    break;
                case 'NS':
                    $value = $record['target'];
                    break;
            }
            $ipAddress = null;
            if (empty($registeredIPs) || !isset($registeredIPs[$value])) {
                $ipAddress = R::dispense('ip_address');
                $ipAddress->created = $updateTimestamp;
                $ipAddress->value = $value;
                $ipAddress->type = $record['type'];
            } else {
                if (isset($registeredIPs[$value])) {
                    $ipAddress = $registeredIPs[$value];
                    unset($registeredIPs[$value]);
                }
            }
            if ($ipAddress instanceof RedBean_OODBBean) {
                $ipAddress->updated = $updateTimestamp;
                R::store($ipAddress);
                R::associate($domain, $ipAddress);
            }
            if ($record['type'] == 'A' && $record['ip'] == $serverIP) {
                $error = false;
            }
        }
        if (!empty($registeredIPs)) {
            foreach ($registeredIPs as $ip) {
                R::unassociate($ip, $domain);
                R::trash($ip);
            }
        }
        if ($error) {
            throw new Exception('Domain does not point to server');
        }
    } else {
        throw new Exception('No A record exists, or domains does not exist');
    }
}
开发者ID:henrik-farre,项目名称:domains,代码行数:64,代码来源:dns-check.php

示例7: save

 public function save($runValidation = true)
 {
     foreach ($this->deferredRelateBeans as $bean) {
         R::associate($this->bean, $bean);
         if (!RedBeanDatabase::isFrozen()) {
             $types = array($this->bean->getMeta("type"), $bean->getMeta("type"));
             sort($types);
             $tableName = implode("_", $types);
             foreach ($types as $type) {
                 $columnName = "{$type}_id";
                 RedBeanColumnTypeOptimizer::optimize($tableName, $columnName, 'id');
             }
         }
     }
     $this->deferredRelateBeans = array();
     foreach ($this->deferredUnrelateBeans as $bean) {
         R::unassociate($this->bean, $bean);
     }
     $this->deferredUnrelateBeans = array();
     return true;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:21,代码来源:RedBeanManyToManyRelatedModels.php

示例8: asrt

}
$book = R::dispense("book");
$page = R::dispense("page");
$book->name = "a";
$page->name = "b";
asrt($marker, false);
R::associate($book, $page);
R::unassociate($book, $page);
asrt($marker, true);
$marker = false;
R::associate($book, $page);
R::unassociate($book, $page);
asrt($marker, true);
$marker = false;
R::associate($book, $page);
R::unassociate($book, $page, true);
asrt($marker, false);
class Model_Cigar extends RedBean_SimpleModel
{
    public static $reachedDeleted = false;
    public static $reachedDispense = false;
    public static $reachedAfterUpdate = false;
    public static $reachedAfterDeleted = false;
    public function after_update()
    {
        self::$reachedAfterUpdate = true;
    }
    public function update()
    {
        $this->rating++;
    }
开发者ID:ryjkov,项目名称:redbean,代码行数:31,代码来源:test.php

示例9: testFastTrackRelations

 /**
  * Fast track link block code should not affect self-referential N-M relations.
  * 
  * @return void
  */
 public function testFastTrackRelations()
 {
     testpack('Test fast-track linkBlock exceptions');
     list($donald, $mickey, $goofy, $pluto) = R::dispense('friend', 4);
     $donald->name = 'D';
     $mickey->name = 'M';
     $goofy->name = 'G';
     $pluto->name = 'P';
     $donald->sharedFriend = array($mickey, $goofy);
     $mickey->sharedFriend = array($pluto, $goofy);
     $mickey->sharedBook = array(R::dispense('book'));
     R::storeAll(array($mickey, $donald, $goofy, $pluto));
     $donald = R::load('friend', $donald->id);
     $mickey = R::load('friend', $mickey->id);
     $goofy = R::load('friend', $goofy->id);
     $pluto = R::load('friend', $pluto->id);
     $names = implode(',', R::gatherLabels($donald->sharedFriend));
     asrt($names, 'G,M');
     $names = implode(',', R::gatherLabels($goofy->sharedFriend));
     asrt($names, 'D,M');
     $names = implode(',', R::gatherLabels($mickey->sharedFriend));
     asrt($names, 'D,G,P');
     $names = implode(',', R::gatherLabels($pluto->sharedFriend));
     asrt($names, 'M');
     // Now in combination with with() conditions...
     $donald = R::load('friend', $donald->id);
     $names = implode(',', R::gatherLabels($donald->withCondition(' name = ? ', array('M'))->sharedFriend));
     asrt($names, 'M');
     // Now in combination with with() conditions...
     $donald = R::load('friend', $donald->id);
     $names = implode(',', R::gatherLabels($donald->with(' ORDER BY name ')->sharedFriend));
     asrt($names, 'G,M');
     // Now counting
     $goofy = R::load('friend', $goofy->id);
     asrt((int) $goofy->countShared('friend'), 2);
     asrt((int) $donald->countShared('friend'), 2);
     asrt((int) $mickey->countShared('friend'), 3);
     asrt((int) $pluto->countShared('friend'), 1);
     R::unassociate($donald, $mickey);
     asrt((int) $donald->countShared('friend'), 1);
     asrt(R::areRelated($donald, $mickey), FALSE);
     asrt(R::areRelated($mickey, $donald), FALSE);
     asrt(R::areRelated($mickey, $goofy), TRUE);
     asrt(R::areRelated($goofy, $mickey), TRUE);
     R::getWriter()->setUseCache(TRUE);
     $mickeysFriends = R::$associationManager->related($mickey, 'friend', TRUE);
     asrt(count($mickeysFriends), 2);
     $mickeysFriends = R::$associationManager->related($mickey, 'friend', TRUE);
     asrt(count($mickeysFriends), 2);
     $plutosFriends = R::$associationManager->related($pluto, 'friend', TRUE);
     asrt(count($plutosFriends), 1);
     $mickeysBooks = R::$associationManager->related($mickey, 'book', TRUE);
     asrt(count($mickeysBooks), 1);
     R::getWriter()->setUseCache(FALSE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:60,代码来源:Relations.php

示例10: testBasicThroughFacade

 /**
  * Basic tests through Facade.
  * 
  * @return void
  */
 public function testBasicThroughFacade()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new RedBean_AssociationManager($toolbox);
     asrt(R::$redbean instanceof RedBean_OODB, TRUE);
     asrt(R::$toolbox instanceof RedBean_Toolbox, TRUE);
     asrt(R::$adapter instanceof RedBean_Adapter, TRUE);
     asrt(R::$writer instanceof RedBean_QueryWriter, TRUE);
     $book = R::dispense("book");
     asrt($book instanceof RedBean_OODBBean, TRUE);
     $book->title = "a nice book";
     $id = R::store($book);
     asrt($id > 0, TRUE);
     $book = R::load("book", (int) $id);
     asrt($book->title, "a nice book");
     $author = R::dispense("author");
     $author->name = "me";
     R::store($author);
     $book9 = R::dispense("book");
     $author9 = R::dispense("author");
     $author9->name = "mr Nine";
     $a9 = R::store($author9);
     $book9->author_id = $a9;
     $bk9 = R::store($book9);
     $book9 = R::load("book", $bk9);
     $author = R::load("author", $book9->author_id);
     asrt($author->name, "mr Nine");
     R::trash($author);
     R::trash($book9);
     pass();
     $book2 = R::dispense("book");
     $book2->title = "second";
     R::store($book2);
     R::associate($book, $book2);
     asrt(count(R::related($book, "book")), 1);
     $book3 = R::dispense("book");
     $book3->title = "third";
     R::store($book3);
     R::associate($book, $book3);
     asrt(count(R::related($book, "book")), 2);
     asrt(count(R::find("book")), 3);
     asrt(count(R::findAll("book")), 3);
     asrt(count(R::findAll("book", " WHERE ROWNUM <= 2")), 2);
     asrt(count(R::find("book", " id=id ")), 3);
     asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
     asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
     // Now with new SQL Helper argument
     asrt(count(R::find("book", R::$f->begin()->addSQL('title LIKE ? ')->put('third'))), 1);
     asrt(count(R::find("book", R::$f->begin()->addSQL('title LIKE ? ')->put('%d%'))), 2);
     asrt(count(R::find("book", R::$f->begin()->addSQL('title')->like(' ? ')->addSQL(' ORDER BY id ')->desc()->put('%d%'))), 2);
     //Find without where clause
     asrt(count(R::findAll('book', ' order by id')), 3);
     R::unassociate($book, $book2);
     asrt(count(R::related($book, "book")), 1);
     R::trash($book3);
     R::trash($book2);
     asrt(count(R::related($book, "book")), 0);
     asrt(count(R::getAll("SELECT * FROM book ")), 1);
     asrt(count(R::getCol("SELECT title FROM book ")), 1);
     asrt((int) R::getCell("SELECT 123 FROM DUAL "), 123);
     $book = R::dispense("book");
     $book->title = "not so original title";
     $author = R::dispense("author");
     $author->name = "Bobby";
     R::store($book);
     $aid = R::store($author);
     R::associate($book, $author);
     $author = R::findOne("author", " name = ? ", array("Bobby"));
     $books = R::related($author, "book");
     $book = reset($books);
     testpack("Test Swap function in R-facade");
     $book = R::dispense("book");
     $book->title = "firstbook";
     $book->rating = 2;
     $id1 = R::store($book);
     $book = R::dispense("book");
     $book->title = "secondbook";
     $book->rating = 3;
     $id2 = R::store($book);
     $book1 = R::load("book", $id1);
     $book2 = R::load("book", $id2);
     asrt($book1->rating, '2');
     asrt($book2->rating, '3');
     $books = R::batch("book", array($id1, $id2));
     R::swap($books, "rating");
     $book1 = R::load("book", $id1);
     $book2 = R::load("book", $id2);
     asrt($book1->rating, '3');
     asrt($book2->rating, '2');
     testpack("Test R::convertToBeans");
     $SQL = "SELECT '1' as id, a.name AS name, b.title AS title, '123' as rating FROM author a LEFT JOIN book b ON b.id = ?  WHERE a.id = ? ";
//.........这里部分代码省略.........
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:101,代码来源:Facade.php

示例11: giveCards

 private function giveCards()
 {
     $deck = new PlayingCardDeck();
     $deck->shuffle();
     // cards for center
     $center_cards = array();
     for ($i = 0; $i < 5; $i++) {
         $center_cards[] = array_merge($deck->drawCard(), array('turned' => $i <= 1 ? true : false));
     }
     $this->_pokerRound->cards = json_encode($center_cards);
     // cards for players
     $first = null;
     $last = null;
     $players = R::related($this->_pokerRound, 'poker_player', ' 1=1 ORDER BY id');
     foreach ($players as $p) {
         // if any player has less than 10 cash, kick him out!
         $usr = R::relatedOne($this->_pokerPlayer, 'user');
         if ($usr->cash < 10) {
             $p->status = 'view';
             R::store($p);
             R::unassociate($this->_pokerRound, $p);
             continue;
         }
         $cards = array();
         $cards[] = $deck->drawCard();
         $cards[] = $deck->drawCard();
         $p->cards = json_encode($cards);
         $p->bid = 10;
         $p->status = 'play';
         $p->game_state = 0;
         $p->all_in = false;
         $p->all_in_amount = 0;
         R::store($p);
         // substract bid
         $usr->cash -= 10;
         R::store($usr);
         $last = $p;
     }
     $this->_pokerRound->current_player = $last;
     $this->_pokerRound->ttl = time() + 60;
     R::store($this->_pokerRound);
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:42,代码来源:Ajax_Poker.class.php


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