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


PHP R::findOne方法代码示例

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


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

示例1: delete

 public function delete($id)
 {
     $item = R::findOne('ecatalog', 'id=?', [$id]);
     R::trash($item);
     @unlink('upload/' . $item['pdf_path']);
     @unlink('upload/' . $item['cover_path']);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/ecatalog');
 }
开发者ID:nuiz,项目名称:duragres,代码行数:8,代码来源:ECatalogController.php

示例2: __invoke

 public function __invoke(Request $req, Response $res, callable $next)
 {
     $res = $next($req, $res);
     $identity = $this->authService->getIdentity();
     if (!$identity) {
         return $res;
     }
     try {
         $user = R::findOne('user', 'mail = ?', [$identity->mail]);
         if (!$user) {
             $user = R::dispense('user');
             $user->uid = $identity->uid;
             $user->mail = $identity->mail;
             $user->display_name = $identity->displayName;
             $user->office_name = $identity->officeName;
             $user->authentication_source = $identity->authenticationSource;
             $user->password = '';
             $user->created = time();
             $user->role = 'school';
             $this->logger->info(sprintf('User %s imported from sso.sch.gr to database', $identity->mail));
         }
         $user->last_login = time();
         $user_id = R::store($user);
         $identityClass = get_class($identity);
         $newIdentity = new $identityClass($user_id, $user->uid, $user->mail, $user->display_name, $user->office_name, $user->authentication_source);
         $this->authService->getStorage()->write($newIdentity);
     } catch (\Exception $e) {
         $this->authService->clearIdentity();
         $this->flash->addMessage('danger', 'A problem occured storing user in database. <a href="%s" title="SSO logout">SSO Logout</a>');
         $this->logger->error('Problem inserting user form CAS in database', $identity->toArray());
         $this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]);
         return $res->withRedirect($this->userErrorRedirectUrl);
     }
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:35,代码来源:CreateUser.php

示例3: test

 public function test(Request $request, Response $response, array $args)
 {
     $uid = $args['uid'];
     $myaccount = R::load('accounts', $uid);
     $accountId = $myaccount->accountid;
     $account = R::findOne('accounts', ' accountid = ?', [$accountId]);
     if (!empty($account)) {
         $apiKey = $account['apikey'];
         $type = $account['servertype'];
         $oandaInfo = new Broker_Oanda($type, $apiKey, $accountId);
     } else {
         $this->flash->addMessage('flash', "Oanda AccountId not found");
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('homepage'));
     }
     $side = 'buy';
     $pair = 'EUR_USD';
     $price = '1.1400';
     $expiry = time() + 60;
     $stopLoss = '1.1300';
     $takeProfit = NULL;
     $risk = 1;
     //        $side='buy';
     //        $pair='GBP_CHF';
     //        $price='2.1443';
     //        $expiry = $oandaInfo->getExpiry(time()+60);
     //        $stopLoss='2.1452';
     //        $takeProfit=NULL;
     //        $risk=1;
     //$oandaInfo->placeLimitOrder($side,$pair,$price,$expiry,$stopLoss,$takeProfit,$risk);
     $oandaInfo->processTransactions();
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:31,代码来源:TestAction.php

示例4: oauthGetData

 /**
  * @RequestMapping(url="oauth/getdata",method="POST",type="json")
  * @RequestParams(true)
  */
 public function oauthGetData($model)
 {
     $this::setupDB();
     \Parichya\OAuthServer::init();
     if (\Parichya\OAuthServer::$PHASE_SERVICE_VERIFICATION) {
         \Parichya\Service::verifyService(function ($publicKey, $privateKey, $authToken) {
             //Verify $publicKey, $privateKey, $authToken and if all valid send requested data
             //R::debug( TRUE );
             $authdata = R::findOne('authtoken', ' authtoken = ? AND publickey = ?', array($authToken, $publicKey));
             if (is_null($authdata)) {
                 return array("success" => false);
             } else {
                 $privateKeyData = R::findOne('subscriber', ' subscriber_privatekey = ? AND subscriber_publickey = ?', array($privateKey, $publicKey));
                 if (is_null($privateKeyData)) {
                     return array("success" => false);
                 } else {
                     $user = R::findOne('users', 'id = ? ', array($authdata->user_id));
                     if (is_null($user)) {
                         return false;
                     } else {
                         return array("success" => true, "otp:authToken" => $authToken, "otp:mobileNumber" => $user->phone, "otp:name" => $user->name, "otp:email" => $user->email);
                     }
                 }
             }
         });
     }
     return "login";
 }
开发者ID:rx-projects,项目名称:sso,代码行数:32,代码来源:MainController.php

示例5: crawlUrl

 public function crawlUrl()
 {
     $currentUrl = ['url' => $this->currentUrl, 'depth' => $this->currentDepth];
     do {
         $this->setCurrentUrl($currentUrl);
         if (!($doc = parent::crawlUrl())) {
             continue;
         }
         $username = $doc['.vcard-username']->text();
         $user = R::findOne('github', ' username = ? ', [$username]);
         //$user = R::find('github', " username=$username ");
         if (empty($user)) {
             $user = R::dispense('github');
             $now = time();
             $user->avatar = $doc['.vcard-avatar .avatar']->attr('src');
             $user->fullname = $doc['.vcard-fullname']->text();
             $user->username = $username;
             $user->email = $doc['.email']->text();
             $user->worksFor = $doc['.vcard-detail[itemprop=worksFor]']->text();
             $user->homeLocation = $doc['.vcard-detail[itemprop=homeLocation]']->text();
             $user->blogUrl = $doc['.vcard-detail[itemprop=url]']->text();
             $user->joinDate = $doc['.join-date']->attr('datetime');
             $user->url = $this->currentUrl;
             $user->createdAt = $now;
             $user->updatedAt = $now;
             if (R::store($user)) {
                 echo '存储用户', $username, '成功', PHP_EOL;
             } else {
                 echo '存储用户', $username, '失败', PHP_EOL;
             }
         } else {
             echo '用户', $username, '已经被存储过了', PHP_EOL;
         }
     } while ($currentUrl = $this->nextUrl());
 }
开发者ID:CraryPrimitiveMan,项目名称:php-spider,代码行数:35,代码来源:GitHub.php

示例6: login

 public function login($request, $response, $args)
 {
     $data = json_decode($request->getBody());
     $user = R::findOne('user', 'username = ?', [$data->username]);
     if ($user === null) {
         $this->logger->addError('Login Attempt', [$data]);
         $this->apiJson->addAlert('error', 'Invalid username or password.');
         return $this->jsonResponse($response, 401);
     }
     if (!password_verify($data->password, $user->password_hash)) {
         $this->logger->addError('Login Attempt ', [$data]);
         $this->apiJson->addAlert('error', 'Invalid username or password.');
         return $this->jsonResponse($response, 401);
     }
     if (!$user->is_active) {
         $this->logger->addError('Login Attempt Inactive User ', [$data]);
         $this->apiJson->addAlert('error', 'This username is not active.');
         return $this->jsonResponse($response, 403);
     }
     $jwt = self::createJwt($user->id, $data->remember ? 100 : 1);
     $user = R::load('user', $user->id);
     $user->active_token = $jwt;
     $user->last_login = time();
     $user->logins += 1;
     R::store($user);
     $this->apiJson->setSuccess();
     $this->apiJson->addData($this->sanitizeUser($user));
     return $this->jsonResponse($response);
 }
开发者ID:kiswa,项目名称:SMPLog,代码行数:29,代码来源:Auth.php

示例7: moveTo

 public function moveTo($id, $position)
 {
     $item = R::findOne($this->table, 'id=?', [$this->id]);
     $desItem = R::findOne($this->table, 'id=?', [$id]);
     $itemOrder = $item->sort_order;
     $destOrder = $desItem->sort_order;
     $item->sort_order = $destOrder;
     $op = $itemOrder < $destOrder ? "-" : "+";
     if ($itemOrder < $destOrder) {
         $op = "-";
         $execParam = [$itemOrder, $destOrder];
     } else {
         $op = "+";
         $execParam = [$destOrder, $itemOrder];
     }
     // if($op == "-" && $position == "before") $destOrder--;
     // if($op == "+" && $position == "after") $destOrder++;
     $query = "UPDATE {$this->table} SET sort_order = sort_order {$op} 1";
     $query .= " WHERE (sort_order BETWEEN ? AND ?) AND id != ?";
     $execParam[] = $this->id;
     if ($op == "-" && $position == "before" || $op == "+" && $position == "after") {
         $query .= " AND id != ?";
         $execParam[] = $id;
         $destOrder2 = $op == "-" && $position == "before" ? $destOrder - 1 : $destOrder + 1;
     } else {
         $destOrder2 = $destOrder;
     }
     R::exec($query, $execParam);
     $item->sort_order = $destOrder2;
     R::store($item);
     $this->makeUnique();
     return true;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:33,代码来源:ECatalogMoveForm.php

示例8: save

 public function save()
 {
     if (!$this->emptyAttr('id')) {
         $menu = R::findOne('menu', 'id=?', [$this->getAttr('id')]);
     } else {
         $menu = R::dispense('menu');
     }
     $menu->name = $this->getAttr('name');
     $oldPicture = null;
     if (!$this->emptyAttr('picture') && $this->attr['picture']->uploaded) {
         $picture = $this->getAttr('picture');
         $picture->file_new_name_body = $this->generateName("menu_picture_");
         // $picture->image_resize = true;
         $picture->image_convert = 'jpeg';
         // $picture->image_x = 964;
         // $picture->image_y = 1024;
         // $picture->image_ratio_y = true;
         $picture->process('upload/');
         $oldPicture = $menu->picture;
         $menu->picture = $picture->file_dst_name;
     }
     $success = R::store($menu);
     if ($success) {
         if (!is_null($oldPicture)) {
             @unlink('upload/' . $oldPicture);
         }
     }
     return $success;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:29,代码来源:MenuForm.php

示例9: findSchoolByRegistryNo

 public function findSchoolByRegistryNo($registryNo)
 {
     $school = R::findOne('school', ' registry_no = ? ', [$registryNo]);
     if (null === $school) {
         return;
     }
     return $this->exportSchool($school);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:8,代码来源:SchoolService.php

示例10: byId

 public static function byId($id)
 {
     $bean = R::findOne('page', ' id = ? ', [$id]);
     if ($bean !== null) {
         return new Page($bean->name, $bean);
     }
     return null;
 }
开发者ID:Koohiisan,项目名称:Enpowi,代码行数:8,代码来源:Page.php

示例11: delete

 public function delete($roomId, $id)
 {
     $item = R::findOne('room_pattern', 'id=?', [$id]);
     @unlink('upload/' . $item->picture);
     @unlink('upload/' . $item->thumb);
     R::trash($item);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/room/' . $roomId . '/pattern');
 }
开发者ID:nuiz,项目名称:duragres,代码行数:8,代码来源:RoomPatternController.php

示例12: findSchoolApplicationForm

 public function findSchoolApplicationForm($schoolId)
 {
     $appForm = R::findOne('applicationform', ' school_id = ? ORDER BY id DESC', [$schoolId]);
     if (null === $appForm) {
         return;
     }
     return $this->exportApplicationForm($appForm);
 }
开发者ID:kanellov,项目名称:gredu_labs,代码行数:8,代码来源:ApplicationFormService.php

示例13: dispatch

 public function dispatch(Request $request, Response $response, array $args)
 {
     $this->logger->info("Profile page action dispatched");
     //grab identity id.
     $id = $this->authenticator->getIdentity();
     $user = R::findOne('users', ' name = :username ', ['username' => $id['name']]);
     $this->view->render($response, 'profile.twig', $user->export());
     return $response;
 }
开发者ID:aodkrisda,项目名称:oncallslim,代码行数:9,代码来源:ProfileAction.php

示例14: __construct

 public function __construct($name, $bean = null)
 {
     $this->name = $name;
     if ($bean === null) {
         $bean = R::findOne('publisher', 'name = :name', ['name' => $name]);
     }
     $this->_bean = $bean;
     $this->convertFromBean();
 }
开发者ID:vallevista,项目名称:etm2.temp,代码行数:9,代码来源:Publisher.php

示例15: get

 public function get($id)
 {
     $item = R::findOne('room', 'id=?', [$id]);
     $itemExport = $item->getProperties();
     $this->build($itemExport);
     header('Content-Type: application/json');
     echo json_encode($itemExport, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:9,代码来源:ApiRoomController.php


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