當前位置: 首頁>>代碼示例>>PHP>>正文


PHP R::load方法代碼示例

本文整理匯總了PHP中RedBeanPHP\R::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP R::load方法的具體用法?PHP R::load怎麽用?PHP R::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RedBeanPHP\R的用法示例。


在下文中一共展示了R::load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: notifyAction

 public function notifyAction()
 {
     $id = 1;
     $settings = R::load('settings', $id);
     $time_before = c::now()->modify('+' . $settings->time_before)->toDateString();
     $transport = \Swift_SmtpTransport::newInstance($settings->mail_host, $settings->mail_port)->setUsername($settings->mail_username)->setPassword($settings->mail_password);
     $mailer = \Swift_Mailer::newInstance($transport);
     $client = new \Services_Twilio($settings->twilio_sid, $settings->twilio_token);
     $recepients = R::findAll('recepients');
     $events = R::find("events", "is_enabled = 1 AND date = '{$time_before}'");
     foreach ($events as $event) {
         foreach ($recepients as $recepient) {
             $subject = preg_replace(array('/{title}/', '/{date}/'), array($event->title, $event->date), $settings->subject);
             $end_date = c::parse($event->date)->modify('+' . $event->days . ' days')->toDateString();
             $body_patterns = array('/{name}/', '/{title}/', '/{start_date}/', '/<!(\\w+) ({\\w+})>/');
             $body_replacements = array($settings->name, $event->title, $event->date, "\$1 {$end_date}");
             if ($event->days == 1) {
                 $body_replacements[3] = '';
             }
             $body = preg_replace($body_patterns, $body_replacements, $settings->msg_template);
             if ($recepient->email && $settings->mail_username && $settings->mail_password) {
                 $message = \Swift_Message::newInstance()->setSubject($subject)->setBody($body)->setFrom(array($settings->email => $settings->name))->setTo(array($recepient->email => $recepient->name));
                 try {
                     $response = $mailer->send($message);
                 } catch (\Exception $e) {
                     //todo: log error
                 }
             } else {
                 if ($recepient->phone_number && $settings->twilio_sid && $settings->twilio_token && $settings->twilio_phonenumber) {
                     $message = $client->account->messages->sendMessage($settings->twilio_phonenumber, $recepient->phone_number, $body);
                 }
             }
         }
     }
 }
開發者ID:anchetaWern,項目名稱:naughtyfire,代碼行數:35,代碼來源:Notifier.php

示例3: getItemCategoryById

 public function getItemCategoryById($id)
 {
     $category = R::load('itemcategory', $id);
     if (!$category->id) {
         throw new InvalidArgumentException('Invalid itemcategory id');
     }
     return $this->exportItemCategory($category);
 }
開發者ID:kanellov,項目名稱:gredu_labs,代碼行數:8,代碼來源:AssetService.php

示例4: add_view

 public function add_view()
 {
     $id = $this->slim->request->post()['id'];
     $item = R::load('ecatalog', $id);
     $item->view_count += 1;
     R::store($item);
     echo '555';
     exit;
 }
開發者ID:nuiz,項目名稱:duragres,代碼行數:9,代碼來源:ApiECatalogController.php

示例5: editRota

 public function editRota(Request $request, Response $response, array $args)
 {
     $id = $this->authenticator->getIdentity();
     if (strtolower($id['name']) != 'admin') {
         $this->flash->addMessage('flash', 'Access Denied');
         return $response->withRedirect($this->router->pathFor('homepage'));
     }
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No rota specified');
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     if ($name != 'new') {
         $rota = R::findOrCreate('rotas', ['name' => $name]);
     } else {
         $rota = R::dispense('rotas');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         //$username = $request->getParam('username');
         $rota->import($data, 'name,fullname,title,comment');
         $rota->sharedUsersList = [];
         foreach ($data['users'] as $checkUserID) {
             $rotaUser = R::load('users', $checkUserID);
             $rota->sharedUsersList[] = $rotaUser;
         }
         $id = R::store($rota);
         try {
             $fieldtest = R::inspect($rota->name);
         } catch (\Exception $e) {
             //thaw for creation
             R::freeze(['users']);
             $rotaUser = R::load('users', 1);
             $rotaDay = R::findOrCreate($rota->name, ['day' => 29, 'month' => 2, 'year' => 2015]);
             $rotaUser = R::load('users', 1);
             $rotaDay->name = $rotaUser;
             $rotaDay->who = $rotaUser;
             $rotaDay->stamp = date("Y-m-d H:i:s");
             R::store($rotaDay);
             R::freeze(true);
         }
         $this->flash->addMessage('flash', "{$rota->name} updated");
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     $userList = R::findAll('users');
     $data = $rota->export();
     $data['userList'] = $userList;
     $users = [];
     $userRota = $rota->sharedUsersList;
     foreach ($userRota as $userCheck) {
         $users[$userCheck->id] = 'checked';
     }
     $data['userCheck'] = $users;
     $this->view->render($response, 'rota.twig', $data);
     return $response;
 }
開發者ID:aodkrisda,項目名稱:oncallslim,代碼行數:56,代碼來源:RotaAction.php

示例6: assert

 public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
 {
     $identity = $this->authService->getIdentity();
     $user = R::load('user', $identity->id);
     if (!($school = $user->school)) {
         return false;
     }
     $appForm = $this->appFormService->findSchoolApplicationForm($school->id);
     return null === $appForm;
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:10,代碼來源:CanSubmit.php

示例7: __invoke

 public function __invoke($req, $res, $next)
 {
     $identity = $this->authService->getIdentity();
     if (!$identity) {
         return $res->withStatus(403, 'No identity');
     }
     $user = R::load('user', $identity->id);
     if (!($school = $user->school)) {
         return $res->withStatus(403, 'No school');
     }
     return $next($req->withAttribute('school', (object) array_merge($school->export(), ['eduadmin' => $school->eduadmin->name, 'regioneduadmin' => $school->eduadmin->regioneduadmin->name])), $res);
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:12,代碼來源:FetchSchoolFromIdentity.php

示例8: __invoke

 public function __invoke(Request $req, Response $res, callable $next)
 {
     $res = $next($req, $res);
     $identity = $this->authService->getIdentity();
     if ($identity && $identity instanceof RoleAwareInterface) {
         $user = R::load('user', $identity->id);
         $role = $user && isset($user->role) ? $user->role : 'user';
         $validRoles = $this->acl->getRoles();
         $role = in_array($role, $validRoles) ? $role : 'user';
         $identity->setRole($role);
         $this->authService->getStorage()->write($identity);
     }
     return $res;
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:14,代碼來源:RoleProvider.php

示例9: edit

 public function edit(Request $request, Response $response, array $args)
 {
     $uid = $args['uid'];
     if (empty($uid)) {
         $this->flash->addMessage('flash', 'No record specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
     }
     $id = $this->authenticator->getIdentity();
     $user = R::load('users', $id['id']);
     if ($uid != 'new') {
         $account = R::load('accounts', $uid);
         if ($account->id == 0) {
             $this->flash->addMessage('flash', 'No record found');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
         }
         // restrict access to own profile or Admin role
         if ($account->users->id != $id['id']) {
             if (strtolower($id['role']) != 'admin') {
                 $this->flash->addMessage('flash', 'Access Denied');
                 return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
             }
         }
     } else {
         $account = R::dispense('accounts');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         $account->import($data, 'apikey,accountid,servertype');
         $account->users = $user;
         $account->lasttid = 0;
         $oandaInfo = FALSE;
         // verify and get account balance
         try {
             $oandaInfo = new Broker_Oanda($account['servertype'], $account['apikey'], $account['accountid'], 0);
         } catch (\Exception $e) {
             $viewData['flash'] = 'Account Details Invalid';
         }
         if ($oandaInfo != FALSE) {
             $aid = R::store($account);
             $oandaInfo->updateAccount();
             $this->flash->addMessage('flash', "account updated");
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('editaccount', ['uid' => $aid]));
         }
     }
     $viewData['account'] = $account;
     $this->view->render($response, 'account.twig', $viewData);
     return $response;
 }
開發者ID:neilmillard,項目名稱:fxtrader,代碼行數:48,代碼來源:AccountAction.php

示例10: convertFromBean

 private function convertFromBean()
 {
     $bean = $this->_bean;
     if (!$this->exists()) {
         return;
     }
     $this->id = $bean->getID();
     $this->name = $bean->name;
     $this->content = $bean->content;
     $this->created = $bean->created;
     $this->user = new User(null, R::load('user', $bean->userId));
     $this->contributors = [];
     foreach ($bean->sharedUser as $contributor) {
         $this->contributors[] = new User(null, $contributor);
     }
 }
開發者ID:Koohiisan,項目名稱:Enpowi,代碼行數:16,代碼來源:Page.php

示例11: testDB

 public function testDB()
 {
     $app = new Application();
     $app->register(new RedBeanServiceProvider(), array('db.options' => array('dsn' => 'sqlite:' . __DIR__ . '/test.sqlite')));
     $app['db'];
     //db init
     $post = R::dispense('post');
     $post->text = 'Hello World';
     $id = R::store($post);
     //Create or Update
     $fetchedPost = R::load('post', $id);
     //Retrieve
     $this->assertSame($post->text, $fetchedPost->text);
     $this->assertTrue(file_exists(__DIR__ . '/test.sqlite'));
     unlink(__DIR__ . '/test.sqlite');
 }
開發者ID:ivoba,項目名稱:redbean-service-provider,代碼行數:16,代碼來源:RedBeanServiceProviderTest.php

示例12: getDetails

 public function getDetails($request, $response, $args)
 {
     $details = R::load('detail', 1);
     if (!$details->id) {
         $details->name = 'SMPLog';
         $details->description = 'A blog published by SMPLog.';
         $details->image = '';
         R::store($details);
     }
     if (empty($details->name)) {
         $details->name = 'SMPLog';
         R::store($details);
     }
     $this->apiJson->setSuccess();
     $this->apiJson->addData($details->export());
     return $this->jsonResponse($response);
 }
開發者ID:kiswa,項目名稱:SMPLog,代碼行數:17,代碼來源:Details.php

示例13: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $identity = $this->authService->getIdentity();
     if (null === $identity) {
         return $res;
     }
     $user = R::load('user', $identity->id);
     if (!$user->school_id) {
         return $res;
     }
     $school_id = $user->school_id;
     $sync = $this->syncFromInventory;
     $result = $sync($school_id);
     if (false === $result) {
         return $res->withStatus(500);
     }
     return $res->withJson($result);
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:18,代碼來源:Sync.php

示例14: __invoke

 public function __invoke(Request $req, Response $res, callable $next)
 {
     $res = $next($req, $res);
     $identity = $this->authService->getIdentity();
     if (null === $identity) {
         return $res;
     }
     $user = R::load('user', $identity->id);
     if (!$user->school_id) {
         return $res;
     }
     $school_id = $user->school_id;
     if (0 < count($this->labService->getLabsBySchoolId($school_id))) {
         return $res;
     }
     $sync = $this->syncFromInventory;
     $sync($school_id);
     return $res;
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:19,代碼來源:CreateLabs.php

示例15: updateRss

 public function updateRss()
 {
     $blog = R::load('blog', 1);
     $posts = R::find('post', ' is_published = 1 ORDER BY publish_date DESC ');
     $xml = $this->getChannelXml($blog);
     $count = 1;
     foreach ($posts as $post) {
         if ($count == 10) {
             break;
         }
         $xml .= $this->getItemXml($post);
         $count++;
     }
     $xml .= "\n\t</channel>" . "\n</rss>";
     try {
         file_put_contents('../rss/rss.xml', $xml);
     } catch (Exception $ex) {
     }
 }
開發者ID:kiswa,項目名稱:SMPLog,代碼行數:19,代碼來源:RssGenerator.php


注:本文中的RedBeanPHP\R::load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。