本文整理匯總了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;
}
示例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());
}
示例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;
}
示例4: createSchool
public function createSchool(array $data)
{
$school = $this->importSchool(R::dispense('school'), $data);
$school->created = time();
R::store($school);
return $this->exportSchool($school);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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']);
}
示例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;
}
}
}
示例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);
}
示例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;
}