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


PHP RedBeanPHP\R类代码示例

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


在下文中一共展示了R类的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: 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

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

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

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

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

 public function setupMySql($host, $name, $user, $password)
 {
     $this->dbHost = $host;
     $this->dbName = $name;
     $this->dbUser = $user;
     $this->dbPassword = $password;
     R::setup('mysql:host=' . $host . ';dbname=' . $name, $user, $password);
     return $this;
 }
开发者ID:Koohiisan,项目名称:Enpowi,代码行数:9,代码来源:Config.php

示例11: select

 protected static function select($a)
 {
     self::init();
     if ($a === 'write') {
         if (self::$_writeConnected && self::$_last === 'write') {
             return;
         }
         foreach (self::$_mcs as $i => $c) {
             R::selectDatabase("write:{$i}");
             if (R::testConnection()) {
                 R::freeze(true);
                 self::$_writeConnected = true;
                 self::$_last = 'write';
                 return;
             }
         }
         throw new \Exception('Master DB have down');
     }
     if ($a === 'read') {
         if (self::$_readConnected && self::$_last === 'read') {
             return;
         }
         foreach (self::$_scs as $i => $c) {
             R::selectDatabase("read:{$i}");
             if (R::testConnection()) {
                 R::freeze(true);
                 self::$_readConnected = true;
                 self::$_last = 'read';
                 return;
             }
         }
         throw new \Exception('Slave and master DB have down');
     }
 }
开发者ID:txthinking,项目名称:buggy,代码行数:34,代码来源:DB.php

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

示例13: addBeans

 function addBeans($beans)
 {
     if (null == $beans) {
         return array();
     }
     $this->data = R::exportAll($beans);
 }
开发者ID:BIGGANI,项目名称:TaskBoard,代码行数:7,代码来源:jsonResponse.php

示例14: getOptions

 public function getOptions()
 {
     $sets = [];
     foreach (R::findAll('skemaset') as $setBean) {
         $sets[$setBean->getID()] = $setBean->name;
     }
     return $sets;
 }
开发者ID:skema,项目名称:skema,代码行数:8,代码来源:SetLink.php

示例15: DBSetup

 public static function DBSetup()
 {
     $config = \Config::getSection("DB1");
     if (!self::$CONNECTED) {
         R::setup('mysql:host=localhost;dbname=' . $config['dbname'], $config['username'], $config['password']);
         self::$CONNECTED = true;
     }
 }
开发者ID:rx-projects,项目名称:comicasa,代码行数:8,代码来源:Service.php


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