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


PHP DatabaseManager::beginTransaction方法代码示例

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


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

示例1: update

 /**
  * updates Activity Document Link
  * @param array                $documentLink
  * @param ActivityDocumentLink $activityDocumentLink
  * @return bool
  */
 public function update(array $documentLink, ActivityDocumentLink $activityDocumentLink)
 {
     try {
         $this->database->beginTransaction();
         $documentLinkExists = $activityDocumentLink->exists;
         $activityId = $activityDocumentLink->activity_id;
         $documentManager = app(DocumentManager::class);
         if ($documentLinkExists) {
             $url = $activityDocumentLink->document_link['url'];
             $document = $documentManager->getDocument(session('org_id'), $url);
             $activities = (array) $document->activities;
             unset($activities[$activityId]);
             $document->activities = $activities;
             $documentManager->update($document);
         }
         $url = $documentLink[0]['url'];
         $document = $documentManager->getDocument(session('org_id'), $url);
         $activities = (array) $document->activities;
         $identifier = $activityDocumentLink->activity->identifier['activity_identifier'];
         $activities[$activityId] = $identifier;
         $document->activities = $activities;
         $documentManager->update($document);
         $this->DocumentLinkRepo->update($documentLink, $activityDocumentLink);
         $this->database->commit();
         $this->logger->info(sprintf('Activity Document Link %s!', $documentLinkExists ? 'updated' : 'saved'), ['for' => $documentLink]);
         $this->dbLogger->activity(sprintf("activity.document_link_%s", $documentLinkExists ? 'updated' : 'saved'), ['activity_id' => $activityDocumentLink->activity_id, 'document_link_id' => $activityDocumentLink->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (\Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['documentLink' => $documentLink]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:39,代码来源:DocumentLinkManager.php

示例2: save

 /**
  * upload activity form csv
  * @param $activityCsv
  * @param $organization
  * @param $defaultFieldValues
  * @return bool
  */
 public function save($activityCsv, $organization, $defaultFieldValues)
 {
     try {
         $excel = $this->version->getExcel();
         $activitiesRows = $excel->load($activityCsv)->get();
         $activityDetails = [];
         foreach ($activitiesRows as $activityRow) {
             $activityDetails[] = $this->uploadActivityRepo->formatFromExcelRow($activityRow, $organization->id);
         }
         $identifiers = $this->uploadActivityRepo->getIdentifiers($organization->id);
         $this->database->beginTransaction();
         $data = [];
         foreach ($activityDetails as $activityDetail) {
             $activityIdentifier = $activityDetail['identifier']['activity_identifier'];
             isset($identifiers[$activityIdentifier]) ? $data[$identifiers[$activityIdentifier]] = $activityDetail : $this->uploadActivityRepo->upload($activityDetail, $organization, $defaultFieldValues);
             $this->database->commit();
         }
         if (count($data) > 0) {
             return view('Activity.confirmUpdate')->withData($data);
         }
         $this->logger->info("Activities Uploaded for organization with id:" . $organization->id);
         $this->dbLogger->activity("activity.activity_uploaded", ['organization_id' => $organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['activity' => $activityDetails]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:36,代码来源:UploadActivityManager.php

示例3: storeMultiple

 /**
  * Save multiple notifications sent
  * at once.
  *
  * @param  array $notifications
  * @return mixed
  */
 public function storeMultiple(array $notifications)
 {
     $this->db->beginTransaction();
     $stackId = $this->db->table($this->notification->getTable())->max('stack_id') + 1;
     foreach ($notifications as $key => $notification) {
         $notifications[$key]['stack_id'] = $stackId;
     }
     $insert = $this->db->table($this->notification->getTable())->insert($notifications);
     $this->db->commit();
     return $insert;
 }
开发者ID:fenos,项目名称:notifynder,代码行数:18,代码来源:NotificationRepository.php

示例4: update

 /**
  * updates Activity Default values
  * @param array    $activityDefaults
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDefaults, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->changeActivityDefaultRepo->update($activityDefaults, $activity);
         $this->database->commit();
         $this->logger->info('Activity Default Values updated!', ['for' => $activityDefaults]);
         $this->dbLogger->activity("activity.activity_default_values", ['organization_id' => $this->auth->user()->organization->id, 'activity_id' => $activity->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['activityDefaultValues' => $activityDefaults]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:ChangeActivityDefaultManager.php

示例5: update

 /**
  * updates title and description of an activity
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->stepTwoRepo->update($activityDetails, $activity);
         $this->database->commit();
         $this->logger->info('Step Two Completed!', ['for' => [$activity->title, $activity->description]]);
         $this->logger->activity("activity.step_two_completed", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['stepTwo' => $activityDetails]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:StepTwoManager.php

示例6: update

 /**
  * update organization total expenditure
  * @param array            $totalExpenditure
  * @param OrganizationData $organizationData
  * @return bool
  */
 public function update(array $totalExpenditure, OrganizationData $organizationData)
 {
     try {
         $this->database->beginTransaction();
         $this->totalExpenditureRepo->update($totalExpenditure, $organizationData);
         $this->database->commit();
         $this->logger->info('Organization Total Expenditure Updated', ['for' => $organizationData->total_expenditure]);
         $this->dbLogger->activity("organization.total_expenditure_updated", ['name' => $this->auth->user()->organization->name]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['TotalExpenditure' => $totalExpenditure]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:TotalExpenditureManager.php

示例7: upgrade

 /**
  * upgrade data version wise
  * @param $orgId
  * @param $version
  * @return bool
  */
 public function upgrade($orgId, $version)
 {
     try {
         $this->database->beginTransaction();
         $this->repo->upgrade($orgId, $version);
         $this->database->commit();
         $this->logger->info(sprintf('Version Upgraded to %s for Organization %s!', $version, $this->auth->user()->organization->name), ['for' => $orgId]);
         $this->dbLogger->activity("activity.version_upgraded", ['organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id, 'version' => $version]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['version' => $version]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:UpgradeManager.php

示例8: update

 /**
  * updates Activity Capital Spend
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->capitalSpendRepo->update($activityDetails, $activity);
         $this->database->commit();
         $this->logger->info('Activity Capital Spend updated!', ['for' => $activity->capital_spend]);
         $this->dbLogger->activity("activity.capital_spend", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['capitalSpend' => $activityDetails]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:CapitalSpendManager.php

示例9: update

 /**
  * updates Activity Country Budget Items
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->CountryBudgetItemRepo->update($activityDetails, $activity);
         $this->database->commit();
         $this->logger->info('Activity Country Budget Items updated!', ['for' => $activity->country_budget_items]);
         $this->logger->activity("activity.country_budget_items", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['countryBudgetItems' => $activityDetails]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:CountryBudgetItemManager.php

示例10: update

 /**
  * update organization total expenditure
  * @param array    $humanitarianScope
  * @param Activity $activity
  * @return bool
  */
 public function update(array $humanitarianScope, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->humanitarianScopeRepo->update($humanitarianScope, $activity);
         $this->database->commit();
         $this->logger->info('Activity Humanitarian Scope Updated', ['for' => $activity->humanitarian_scope]);
         $this->dbLogger->activity("activity.humanitarian_scope_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['HumanitarianScope' => $humanitarianScope]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:HumanitarianScopeManager.php

示例11: update

 /**
  * update recipient region budget
  * @param array            $input
  * @param OrganizationData $organization
  * @return bool
  */
 public function update(array $input, OrganizationData $organization)
 {
     try {
         $this->database->beginTransaction();
         $this->repo->update($input, $organization);
         $this->database->commit();
         $this->logger->info('Organization Recipient Region Budget Updated', ['for' => $organization->recipient_region_budget]);
         $this->dbLogger->activity("organization.recipient_region_budget_updated", ['name' => $this->auth->user()->organization->name]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['OrganizationRecipientRegionBudget' => $input]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:RecipientRegionBudgetManager.php

示例12: execute

 /**
  * Wrap a command execution in a database transaction.
  *
  * @param  object    $command
  * @param  callable  $next
  * @return mixed
  *
  * @throws Exception
  * @throws Throwable
  */
 public function execute($command, callable $next)
 {
     $this->database->beginTransaction();
     try {
         $returnValue = $next($command);
         $this->database->commit();
     } catch (Exception $exception) {
         $this->database->rollBack();
         throw $exception;
     } catch (Throwable $exception) {
         $this->database->rollBack();
         throw $exception;
     }
     return $returnValue;
 }
开发者ID:tillkruss,项目名称:laravel-tactician,代码行数:25,代码来源:TransactionMiddleware.php

示例13: update

 /**
  * updates Activity Default Aid Type
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->defaultAidTypeRepo->update($activityDetails, $activity);
         $this->database->commit();
         $this->logger->info('Activity Default Aid Type updated!', ['for' => $activity->default_aid_type]);
         $this->dbLogger->activity("activity.default_aid_type", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['defaultAidType' => $activityDetails]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:21,代码来源:DefaultAidTypeManager.php

示例14: update

 /**
  * Update Activity Result
  * @param array          $resultData
  * @param ActivityResult $activityResult
  * @return bool
  */
 public function update(array $resultData, ActivityResult $activityResult)
 {
     try {
         $this->database->beginTransaction();
         $resultExists = $activityResult->exists;
         $this->resultRepo->update($resultData, $activityResult);
         $this->database->commit();
         $this->logger->info(sprintf('Activity Result %s!', $resultExists ? 'updated' : 'saved'), ['for' => $activityResult->result]);
         $this->dbLogger->activity(sprintf("activity.result_%s", $resultExists ? 'updated' : 'saved'), ['activity_id' => $activityResult->activity_id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['result' => $resultData]);
     }
     return false;
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:22,代码来源:ResultManager.php

示例15: update

 /**
  * @param $id
  * @param $formData
  * @return bool
  */
 public function update($id, $formData)
 {
     $tags = [];
     if (isset($formData['tag'])) {
         $tags = $this->tag->createOrGet($formData['tag']);
     }
     $this->database->beginTransaction();
     try {
         $question = $this->find($id);
         if (!$question->update($formData)) {
             return false;
         }
         $question->tags()->sync($tags);
         $this->saveAnswers($formData, $question);
         $this->saveSubQuestions($formData, $question);
         $this->database->commit();
         return $question;
     } catch (\Exception $e) {
         dd($e);
         $this->database->rollback();
         return false;
     }
     $this->database->rollback();
     return false;
 }
开发者ID:Shuvayatra,项目名称:migration-web,代码行数:30,代码来源:QuestionService.php


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