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


PHP R::store方法代碼示例

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


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

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

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

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

 public function createSchool(array $data)
 {
     $school = $this->importSchool(R::dispense('school'), $data);
     $school->created = time();
     R::store($school);
     return $this->exportSchool($school);
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:7,代碼來源:SchoolService.php

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

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

示例7: link

 /**
  * @param Set $linkedSet
  * @returns $this
  */
 public function link(Set $linkedSet)
 {
     $bean = $this->getBean();
     if ($bean === null) {
         $bean = $this->newBean();
     }
     $bean->{$this->_('linkedSetId')} = $linkedSet->getBean()->getID();
     R::store($bean);
     return $this;
 }
開發者ID:skema,項目名稱:skema,代碼行數:14,代碼來源:SetLink.php

示例8: setOptions

 public function setOptions($options)
 {
     $bean = $this->getBean();
     if ($bean === null) {
         $bean = $this->newBean();
     }
     $bean->{$this->_('options')} = implode(',', $options);
     R::store($bean);
     return $this;
 }
開發者ID:skema,項目名稱:skema,代碼行數:10,代碼來源:DropDown.php

示例9: store

function store()
{
    $email = R::dispense('email');
    foreach (\app\run('input', 'keys', 'post') as $key) {
        $element = str_replace('-', '_', $key);
        $email->{$element} = \app\run('input', 'post', $key);
    }
    R::store($email);
    return null;
}
開發者ID:draganescu,項目名稱:sibip-commands,代碼行數:10,代碼來源:store.php

示例10: updateAssetForSchool

 public function updateAssetForSchool($school_id, array $assetData, $assetId)
 {
     $asset = R::findOne('schoolasset', ' id = ? AND school_id = ? ', [$assetId, $school_id]);
     if (!$asset) {
         throw new InvalidArgumentException('No school asset found');
     }
     $asset = $this->importSchoolAsset($asset, $assetData, $school_id);
     R::store($asset);
     return $this->exportSchoolAsset($asset);
 }
開發者ID:kanellov,項目名稱:gredu_labs,代碼行數:10,代碼來源:AssetService.php

示例11: makeUnique

 public function makeUnique()
 {
     $items = R::find($this->table, 'ORDER BY sort_order');
     // $items = R::exportAll($items);
     $i = 0;
     foreach ($items as $key => $item) {
         $i++;
         $item->sort_order = $i;
         R::store($item);
     }
 }
開發者ID:nuiz,項目名稱:duragres,代碼行數:11,代碼來源:ECatalogMoveForm.php

示例12: testGetDetailsCustom

 public function testGetDetailsCustom()
 {
     $details = R::dispense('detail');
     $details->desc = 'A test blog.';
     $details->image = 'some url';
     R::store($details);
     $response = $this->details->getDetails(new RequestMock(), new ResponseMock(), null);
     $this->assertEquals('success', $response->status);
     $this->assertEquals('SMPLog', $response->data[0]['name']);
     $this->assertEquals('A test blog.', $response->data[0]['desc']);
 }
開發者ID:kiswa,項目名稱:SMPLog,代碼行數:11,代碼來源:DetailsTest.php

示例13: storeForm

 public static function storeForm($form)
 {
     $data = DataBase::processForm($form);
     foreach ($data as $table => $value) {
         try {
             $saved = parent::store($value);
         } catch (\Exception $e) {
             return $e;
         }
     }
 }
開發者ID:nexhero,項目名稱:muffin,代碼行數:11,代碼來源:DataBase.php

示例14: persist

 private function persist($teacher, array $data)
 {
     $teacher->school_id = $data['school_id'];
     $teacher->name = $data['name'];
     $teacher->surname = $data['surname'];
     $teacher->telephone = $data['telephone'];
     $teacher->email = $data['email'];
     $teacher->branch_id = $data['branch_id'];
     $teacher->is_principle = isset($data['is_principle']);
     $teacher->is_responsible = isset($data['is_responsible']);
     R::store($teacher);
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:12,代碼來源:StaffService.php

示例15: checkIn

 public static function checkIn($number)
 {
     $bean = R::findOne('record', ' number = :number AND isnull(`in`) ', ['number' => $number]);
     if ($bean === null) {
         return null;
     }
     $bean->in = time();
     $bean->checkInBy = App::user()->id;
     $record = new Record($number, $bean);
     R::store($bean);
     return $record;
 }
開發者ID:vallevista,項目名稱:etm2.temp,代碼行數:12,代碼來源:Record.php


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