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


PHP R::findOne方法代码示例

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


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

示例1: render

 public function render()
 {
     // Create the path titles with urls
     $parents = explode('/', $this->page->slug);
     $current = current(array_reverse($parents));
     debug("Current" . $current);
     $urls = [];
     foreach ($parents as $slug) {
         if ($slug == $current) {
             break;
         }
         $parentp = R::findOne('page', 'slug = :slug', ['slug' => $slug]);
         $title = $parentp->title;
         $title = current(explode(' | ', $title));
         foreach (self::$remove as $string) {
             $title = str_replace($string, '', $title);
         }
         $exploded = explode(' | ', $title);
         foreach ($exploded as $rem) {
             self::$remove[] = $rem;
         }
         $title = str_replace('|', '', $title);
         $title = trim($title);
         $u = ['label' => $title, 'href' => $parentp->slug];
         $urls[] = $u;
     }
     $title = $this->page->title;
     $title = current(explode(' | ', $title));
     foreach (self::$remove as $string) {
         $title = str_replace($string, '', $title);
     }
     //		$title = trim(str_replace('|', '', $title));
     $urls[] = ['label' => $title, 'href' => $this->page->slug];
     return Theme_Loader::get_instance()->render_file('modules/breadcrumb/breadcrumb.twig', ['urls' => $urls]);
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:35,代码来源:Breadcrumb.php

示例2: douban_callback

function douban_callback()
{
    OAuthRequester::requestAccessToken(DOUBAN_KEY, $_SESSION['oauth_token'], 0, 'POST', $options = array('oauth_verifier' => $_SESSION['oauth_token']));
    $req = new OAuthRequester('http://api.douban.com/people/' . urlencode('@me'), 'get');
    $res = $req->doRequest();
    $user_data = new SimpleXMLElement($res['body']);
    $uid = array_pop(explode('/', $user_data->id));
    $auth_type = 'douban';
    $auth = R::findOne('oauth', "uid=? AND type=?", array($uid, $auth_type));
    if (!$auth) {
        $auth = R::dispense('oauth');
        $auth->uid = $uid;
        $auth->type = $auth_type;
        $encrypt_key = rand(100000, 999999);
        $auth->secret = $encrypt_key;
    } else {
        $encrypt_key = $auth->secret;
    }
    $cookie_str = sha1(implode('', array($uid, $auth_type, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $encrypt_key)));
    $expire = time() + 3600 * 24 * 365;
    setcookie('s', $cookie_str, $expire);
    setcookie('auth_type', $auth_type, $expire);
    setcookie('uid', $uid, $expire);
    $auth->setMeta('buildcommand.unique', array(array('uid', 'type')));
    $auth->setMeta('buildcommand.indexes', array('uid' => 'uid'));
    R::store($auth);
}
开发者ID:reusee,项目名称:defphp,代码行数:27,代码来源:douban_oauth.php

示例3: getEventDetails

 /**
  * Function to get event details by event id
  * @param  int $eventId Id of the event for which details are to be found
  * @param  int $userId  Id of the user who is seeing the event
  * @return array
  * **/
 public function getEventDetails($eventId, $userId)
 {
     $return['event_details'] = array();
     $return['userParticiaptionStatus'] = null;
     $return['participantDetails'] = array();
     // get event details
     $eventDetails = \R::findOne($this->_name, 'id = :eid AND status = 1', array(':eid' => $eventId));
     if ($eventDetails) {
         // get details of participants
         $getUserParticipationDetails = "SELECT u.id as userid ,u.first_name,u.last_name ,upe.participation_id\r\n                                        FROM users_events_participation upe \r\n                                        JOIN users u ON upe.users_id = u.id AND upe.events_id = :eId\r\n                                        WHERE upe.participation_id IN (1,3)\r\n                                        ORDER BY (u.id = :uId) DESC, u.id";
         $rows = \R::getAll($getUserParticipationDetails, array(':eId' => $eventId, ':uId' => $userId));
         $return['event_details'] = $eventDetails->export(false);
         $usersParticpating = array();
         // array containing profile pic of the user who are participating
         $objServerInfo = new \services\helpers\ServerInfo();
         if (!empty($rows)) {
             // if first row is for given user then handle it accordingly
             if ($rows[0]['userid'] == $userId) {
                 $return['userParticiaptionStatus'] = $rows[0]['participation_id'];
                 unset($rows[0]);
             }
             // details f other participants
             foreach ($rows as $record) {
                 $profilepic = $objServerInfo->getScheme() . "://" . $objServerInfo->getHost() . APPLICATION_BASE . 'images/' . $record['userid'] . '_pp.jpg';
                 $picPath = APPLICATION_DIR . "/images/{$record['userid']}_pp.jpg";
                 $record['profilepic'] = @is_file($picPath) ? $profilepic : null;
                 $usersParticpating[] = $record;
             }
         }
         $return['participantDetails'] = $usersParticpating;
     }
     return $return;
 }
开发者ID:samiksha-singla,项目名称:Api-Framework,代码行数:39,代码来源:Events.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: init

 /**
  * this is stupid
  * @see Controller_GameAuth::init()
  */
 public function init()
 {
     // check if logged in session is valid, if not redir to main page
     if (!isset($_SESSION['loginHash'])) {
         $this->error('not_loggedin');
         die;
     }
     // check if secure hash is valid
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!$this->checkSecureHash($_POST['fSecureHash'])) {
             $this->error('Ungültiger fSecureHash.');
             die;
         }
     }
     $activeSession = R::findOne('session', ' hash = ? AND ip = ? AND expires > ?', array($_SESSION['loginHash'], $_SERVER['REMOTE_ADDR'], time()));
     if (!$activeSession) {
         unset($_SESSION['loginHash']);
         $this->error('not_loggedin');
         die;
     }
     $activeSession->expires = time() + SESSION_MAX_AGE;
     R::store($activeSession);
     $this->session = $activeSession;
     $this->user = $this->session->user;
     //R::load('user', $this->session->user->getId());
     // check needed rights if any
     foreach ($this->_rights as $r) {
         if (!$this->user->hasRight($r)) {
             $this->error('no_rights');
             die;
         }
     }
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:37,代码来源:Controller_AjaxGame.class.php

示例6: save

 public function save()
 {
     GUMP::add_validator("unique", function ($field, $input, $param = NULL) {
         $checkExistingUser = R::findOne('user', 'user=?', array($input));
         if ($checkExistingUser == NULL) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     GUMP::add_validator("strong", function ($field, $input, $param = NULL) {
         return checkPasswordStrength($input);
     });
     $rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong');
     $filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5');
     $app = Slim::getInstance();
     $post = $app->request()->post();
     // $app - Slim main app instance
     $postValues = $gump->filter($post, $filters);
     $validated = $gump->validate($gump->filter($postValues, $filters), $rules);
     if ($validated === TRUE) {
         $createUser = R::dispense('user');
         $createUser->user = $postValues['reseller_username'];
         $createUser->user = $postValues['reseller_password'];
     } else {
         $this->setError($gump->get_readable_errors(true));
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:33,代码来源:reseller_library.php

示例7: getByName

 /**
  * Given a name, get the custom field data model.  Attempts to retrieve from cache, if it is not available,
  * will attempt to retrieve from persistent storage, cache the model, and return.
  * @param string $name
  * @return CustomFieldData model
  * @throws NotFoundException
  */
 public static function getByName($name, $shouldCache = true)
 {
     if (isset(self::$cachedModelsByName[$name])) {
         return self::$cachedModelsByName[$name];
     }
     try {
         return GeneralCache::getEntry('CustomFieldData' . $name);
     } catch (NotFoundException $e) {
         assert('is_string($name)');
         assert('$name != ""');
         $bean = R::findOne('customfielddata', "name = :name ", array(':name' => $name));
         assert('$bean === false || $bean instanceof RedBean_OODBBean');
         if ($bean === false) {
             $customFieldData = new CustomFieldData();
             $customFieldData->name = $name;
             $customFieldData->serializedData = serialize(array());
             // An unused custom field data does not present as needing saving.
             $customFieldData->setNotModified();
         } else {
             $customFieldData = self::makeModel($bean);
         }
         if ($shouldCache) {
             self::$cachedModelsByName[$name] = $customFieldData;
             GeneralCache::cacheEntry('CustomFieldData' . $name, $customFieldData);
         }
         return $customFieldData;
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:35,代码来源:CustomFieldData.php

示例8: show_Chat

    public function show_Chat()
    {
        $lastMessage = $_POST["time"];
        if ($lastMessage < 0 || !is_numeric($lastMessage)) {
            $this->error('Invalid lastMessage-Timestamp');
        }
        if ($lastMessage < time() - CHAT_LIFETIME) {
            $lastMessage = time() - CHAT_LIFETIME;
        }
        $messages = R::find('chat_message', ' map = ? AND time > ?
		AND ((type = ? || (type = ? AND visible_for_id = ?)) || player_id = ?) ORDER BY time ASC', array($this->mapPosition->map, $lastMessage, 'public', 'private', $this->user->id, $this->user->id));
        $m = array();
        $latest = $lastMessage;
        foreach ($messages as $msg) {
            $to = "";
            $type = $msg->player_id != null && $msg->player_id == $this->user->id ? "own" : $msg->type;
            if ($type == "own" && $msg->visible_for_id != null) {
                $p = R::findOne('user', ' id = ?', array($msg->visible_for_id));
                if ($p != false) {
                    $to = htmlspecialchars($p->username);
                }
            }
            $m[] = array('time' => date("H:i:s", $msg->time), 'author' => htmlspecialchars($msg->author), 'pid' => $msg->player_id != null ? $msg->player_id : "-1", 'text' => $msg->text, 'type' => $type, 'to' => $to);
            $latest = $msg->time;
        }
        $this->output('messages', $m);
        $this->output('timestamp', $latest);
    }
开发者ID:agrafix,项目名称:managerslife,代码行数:28,代码来源:Ajax_Map.class.php

示例9: getByUrl

 public static function getByUrl($url)
 {
     $data = R::findOne('page', 'url=?', [$url]);
     if (!empty($data)) {
         $data['body'] = Page::getBody(_WEB . Page::$buffer_dir . $data['filename'] . '.html');
     }
     return $data;
 }
开发者ID:Elrenardo,项目名称:FoxFWcms-4,代码行数:8,代码来源:Page.php

示例10: isBanned

 public static function isBanned($type, $value)
 {
     $ban = R::findOne('banlist', ' type=:type AND value=:value ', array(':type' => $type, ':value' => $value));
     if (isset($ban) && $ban->id) {
         return true;
     }
     return false;
 }
开发者ID:zeamxie,项目名称:jobskee-open-source-job-board,代码行数:8,代码来源:Banlist.php

示例11: load_data

 function load_data($slug)
 {
     $page = R::findOne('page', 'slug = :slug', ['slug' => $slug]);
     if (empty($page)) {
         $page = $this->create_data($slug);
     }
     return $page;
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:8,代码来源:Page.php

示例12: show_Use

    public function show_Use()
    {
        $userPos = R::findOne('map_position', ' user_id = ?', array($this->user->getID()));
        $this->output('maintext', 'Dieser Teleporter ist ein Admin-Item. Damit kannst du dich durch
		die Gegend teleportieren');
        $this->output('form', array('target' => 'teleport', 'elements' => array(array('desc' => 'X', 'name' => 'x', 'type' => 'text'), array('desc' => 'Y', 'name' => 'y', 'type' => 'text'), array('name' => 'map', 'desc' => 'Karte', 'type' => 'select', 'options' => array('main' => 'Main', 'main2' => 'Main2', 'main3' => 'Main3', 'supermarket' => 'Supermarkt', 'livinghouse' => 'Wohnhaus'), 'value' => $userPos->map))));
        //$this->output('options', array('use' => 'Zurück'));
    }
开发者ID:agrafix,项目名称:managerslife,代码行数:8,代码来源:Ajax_Item_teleporter.class.php

示例13: showBlockBySlug

 public static function showBlockBySlug($name)
 {
     $block = R::findOne('blocks', " url=:url ", array(':url' => $name));
     if (isset($block) && $block->id) {
         echo $block->content;
     }
     return false;
 }
开发者ID:zeamxie,项目名称:jobskee-open-source-job-board,代码行数:8,代码来源:Blocks.php

示例14: isValidAccessKey

 public function isValidAccessKey($accessKeyId)
 {
     $row = \R::findOne($this->_name, 'access_key_id = :akid', array(':akid' => $accessKeyId));
     if ($row) {
         return $row;
     }
     return false;
 }
开发者ID:samiksha-singla,项目名称:Api-Framework,代码行数:8,代码来源:ApiProducts.php

示例15: update

 /**
     Update - automatically called by RedBean when stored.
 */
 public function update()
 {
     parent::update();
     $test = R::findOne("subscription", "email=? and id<>?", array($this->email, $this->id));
     if ($test) {
         $this->bean->id = $test->id;
     }
 }
开发者ID:paulk12,项目名称:redskeleton,代码行数:11,代码来源:subscription.php


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