本文整理汇总了PHP中DB::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::commit方法的具体用法?PHP DB::commit怎么用?PHP DB::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* Setup global $DB as original DB object again.
*/
function tearDown()
{
$this->test_DB->commit();
if ($this->test_DB->error) {
$this->fail('There has been a DB error.');
}
$this->dropTestDbTables();
$GLOBALS['DB'] =& $this->old_DB;
parent::tearDown();
}
示例2: commit
public function commit()
{
$this->assertFinished();
$this->finished = true;
if (!$this->savepointName) {
$this->db->commit();
} else {
$this->db->savepointRelease($this->savepointName);
}
}
示例3: postEditar
/**
* Update the specified resource in storage.
* POST /cargo/editar
*
* @return Response
*/
public function postEditar()
{
if (Request::ajax()) {
$sql = "";
$cargoId = Input::get('id');
$array = array();
$array['grupo_persona_id'] = Input::get('grupop');
$array['cargo_estrategico_id'] = Input::get('cargo');
$cargo_estrategico = Input::get('cargo');
$array['id'] = $cargoId;
DB::beginTransaction();
DB::table('grupos_cargos')->where('grupo_persona_id', Input::get('grupop'))->update(array('estado' => 0));
for ($i = 0; $i < count($cargo_estrategico); $i++) {
$sql = " SELECT id\n FROM grupos_cargos\n WHERE grupo_persona_id='" . Input::get('grupop') . "'\n AND cargo_estrategico_id='" . $cargo_estrategico[$i] . "'";
$rf = DB::select($sql);
if (count($rf) > 0) {
$cargo = GrupoCargo::find($rf[0]->id);
$cargo->fecha_inicio = Input::get('fecha_inicio');
$cargo->estado = 1;
$cargo->usuario_updated_at = Auth::user()->id;
$cargo->save();
} else {
$cargo = new GrupoCargo();
$cargo->grupo_persona_id = Input::get('grupop');
$cargo->cargo_estrategico_id = $cargo_estrategico[$i];
$cargo->fecha_inicio = Input::get('fecha_inicio');
$cargo->estado = 1;
$cargo->usuario_created_at = Auth::user()->id;
$cargo->save();
}
}
DB::commit();
return Response::json(array('rst' => 1, 'msj' => 'Registro actualizado correctamente'));
}
}
示例4: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//dd($this->req);
\DB::begintransaction();
$me = \Me::data()->id_karyawan;
// Create PO
$po = data_po::create(['id_sph' => $this->req['id'], 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => $me, 'id_acc' => 0, 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket'], 'titipan' => $this->req['titipan']]);
foreach ($this->req['id_barang'] as $i => $id_barang) {
data_po_item::create(['id_po' => $po->id_po, 'id_item' => $id_barang, 'req_qty' => $this->req['qty'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i], 'id_prq' => $this->req['id_prq'][$i]]);
data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]);
// update Harga
data_barang::find($id_barang)->update(['harga_beli' => $this->req['harga'][$i]]);
// Update Log harga
data_harga::create(['id_barang' => $id_barang, 'harga' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me, 'tipe' => 1]);
data_prq_item::find($this->req['id_prq_item'][$i])->update(['status' => 2]);
}
$format = 'PO-';
$po->no_po = $format . \Format::code($po->id_po);
$po->save();
\Loguser::create('Membuat PO dengan No. PO ' . $po->no_po);
\DB::commit();
return ['result' => true, 'err' => 'PO berhasil dibuat dengan No. ' . $po->no_po];
} catch (\Exception $e) {
\DB::rollback();
return ['result' => false, 'err' => $e->getMessage()];
}
}
示例5: create
public function create(array $data)
{
DB::beginTransaction();
try {
$data['status'] = 0;
if (isset($data['cupom_code'])) {
$cupom = $this->cupomRepository->findByField('code', $data['cupom_code'])->first();
$data['cupom'] = $cupom->id;
$cupom->used = 1;
$cupom->save();
unset($data['cupom_code']);
}
$items = $data['items'];
unset($data['items']);
$order = $this->orderRepository->create($data);
$total = 0;
foreach ($items as $item) {
$item['price'] = $this->productRepository->find($item['product_id'])->price;
$order->items()->create($item);
$total += $item['price'] * $item['qtd'];
}
$order->total = $total;
if (isset($cupom)) {
$order->total = $total - $cupom->value;
}
$order->save();
\DB::commit();
} catch (\Exception $e) {
\DB::rollback();
throw $e;
}
}
示例6: postSchimbaStadiu
public function postSchimbaStadiu($id_livrabil)
{
$actualizare_ore = Input::get('ore_lucrate') > 0;
$is_stadiu = Input::get('stadiu_selectionat') != null && Input::get('stadiu_selectionat') > 0;
$array_update = array();
if ($is_stadiu) {
//Face insert in tabela de istoric de stadii
//Actualizeaza stadiul livrabilului
$array_update = array_add($array_update, 'id_stadiu', Input::get('stadiu_selectionat'));
}
if ($actualizare_ore) {
//Actualizeaza numarul de ore lucrate la acest livrabil
$array_update = array_add($array_update, 'ore_lucrate', Input::get('ore_lucrate'));
}
// Start transaction!
DB::beginTransaction();
if ($is_stadiu) {
try {
DB::table('istoric_stadii_livrabil')->insertGetId(array('id_livrabil_etapa' => Input::get('id_livrabil_etapa'), 'id_stadiu' => Input::get('stadiu_selectionat'), 'id_user' => Entrust::user()->id));
} catch (Exception $e) {
DB::rollback();
return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
}
}
if ($is_stadiu || $actualizare_ore) {
try {
DB::table('livrabile_etapa')->where('id', Input::get('id_livrabil_etapa'))->update($array_update);
} catch (Exception $e) {
DB::rollback();
return Redirect::back()->with('message', 'Eroare salvare date: ' . $e);
}
}
DB::commit();
return Redirect::back()->with('message', 'Actualizare realizata cu succes!')->withInput();
}
示例7: changePassword
function changePassword()
{
$validator = new Validate();
$validated = $validator->validateNewPassword();
if ($validated->fails()) {
return \View::make('accounts.password')->withErrors($validated);
}
if (\Auth::check()) {
$hashed = \Hash::make(\Input::get('password'));
$id = \Auth::user()->user_id;
\DB::beginTransaction();
try {
$statement = \User::find($id);
$statement->password = $hashed;
$statement->save();
} catch (ValidationException $e) {
DB::rollback();
throw $e;
}
\DB::commit();
\Auth::logout();
return \Redirect::to('admin/logout')->with('message', '<div class="alert alert-dismissible alert-success alert-link">
<button type="button" class="close" data-dismiss="alert">×</button>
Password changed. Please log in.
</div>');
}
return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">
<button type="button" class="close" data-dismiss="alert">×</button>
Password changed. Please log in.
</div>');
}
示例8: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
\DB::begintransaction();
$me = \Me::data()->id_karyawan;
$retur = data_retur::create(['tipe' => 2, 'id_po' => $this->req['id_po'], 'id_vendor' => $this->req['id_vendor'], 'id_karyawan' => $me]);
data_po::find($this->req['id_po'])->update(['status' => 2]);
foreach ($this->req['id_barang'] as $i => $id_barang) {
if (!empty($this->req['qty'][$i])) {
data_retur_item::create(['id_retur' => $retur->id_retur, 'id_barang' => $id_barang, 'id_satuan' => $this->req['id_satuan'][$i], 'qty' => $this->req['qty'][$i], 'qty_lg' => $this->req['qty'][$i]]);
// Log Stok
data_log_barang::create(['id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'id_gudang' => 0, 'kondisi' => 2, 'tipe' => 5, 'id_parent' => $retur->id_retur, 'id_karyawan' => $me]);
// Update stok
$barang = data_barang::find($id_barang);
$barang->out = $barang->out + $this->req['qty'][$i];
$barang->save();
// Update data PO items
$itm = data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->first();
$qpo = $itm->qty + $this->req['qty'][$i];
data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->update(['qty' => $qpo, 'status' => 1]);
}
}
$format = 'EX-RTN-';
$kode = $format . \Format::code($retur->id_retur);
$retur->no_retur = $kode;
$retur->save();
\Loguser::create('Membuat Retur Pembelian dengan No. ' . $kode);
\DB::commit();
return ['result' => true, 'label' => 'success', 'err' => 'Return Pembelian berhasil dibuat dengan No. ' . $kode];
} catch (\Exception $e) {
\DB::rollback();
return ['result' => false, 'label' => 'danger', 'err' => $e->getMessage()];
}
}
示例9: store
/**
* Creates a new entry, puts the id into the session and
* redirects back to the index page.
*/
public function store()
{
if (Entry::canCreateOrEdit() === false) {
return Redirect::route('entry.index')->withMessage("Sorry, the competition has now started and new entries cannot be created.");
}
$input = Input::all();
$validator = Validator::make($input, Entry::$entry_rules);
if ($validator->fails()) {
return Redirect::route('entry.create')->withInput()->withErrors($validator);
}
DB::beginTransaction();
$entry = new Entry();
$entry->email = $input['email'];
$entry->secret = Hash::make($input['secret']);
$entry->confirmation = uniqid('', true);
$entry->first_name = $input['first_name'];
$entry->last_name = $input['last_name'];
$entry->peer_group = $input['peer_group'];
$entry->save();
$matches = Match::all();
foreach ($matches as $match) {
$match_prediction = new MatchPrediction();
$match_prediction->team_a = $match->team_a;
$match_prediction->team_b = $match->team_b;
$match_prediction->pool = $match->pool;
$match_prediction->match_date = $match->match_date;
$entry->matchPredictions()->save($match_prediction);
}
DB::commit();
$this->sendConfirmationEmail($entry);
$this->putEntryIdIntoSession($entry->id);
return View::make('entry.edit')->with('entry', $entry);
}
示例10: postRegistroEmpresas
public function postRegistroEmpresas()
{
DB::beginTransaction();
try {
$empresa = new LandingEmpresa();
$empresa->razon_social = ucwords(strtolower(Input::get('empresa_razonsocial')));
$empresa->ruc = Input::get('empresa_ruc');
$empresa->inscritos = Input::get('empresa_inscritos');
$empresa->domicilio = Input::get('empresa_domicilio');
$empresa->email = Input::get('empresa_email');
$empresa->telefono = Input::get('empresa_telefono');
$empresa->celular = Input::get('empresa_celular');
$empresa->curso = Input::get('empresa_curso');
$empresa->comentario = Input::get('empresa_comentario');
$empresa->recibir_noticias = Input::get('empresa_informacion');
$empresa->ip = Request::getClientIp(true);
$empresa->save();
$respuesta = array('status' => 'ok');
DB::commit();
} catch (\Exception $e) {
DB::rollback();
$respuesta = array('status' => 'error', 'messages' => 'Exception with msg: ' . $e->getMessage());
}
return Response::json($respuesta, 200);
}
示例11: deleteCategoryInfo
public function deleteCategoryInfo($slug)
{
$results = \MenuCategory::where('menu_category_slug', '=', $slug)->get();
foreach ($results as $result) {
$id = $result->menu_category_id;
}
$items_using_cat = \MenuItem::where('menu_item_category_fk', '=', $id)->get();
foreach ($items_using_cat as $item_using_cat) {
if ($item_using_cat) {
return \Redirect::to("admin/category/edit/{$slug}")->with('message', '<div class="alert alert-dismissible alert-danger alert-link">Unable to delete category. Please make sure no items are using this category.</p></div>');
}
}
//if an item exists that has this cat's fk, reload the page with an error
if (\Auth::check()) {
\DB::beginTransaction();
try {
$statement = \MenuCategory::find($id);
$statement->delete();
} catch (ValidationException $e) {
DB::rollback();
throw $e;
}
\DB::commit();
return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">Category has been deleted</p></div>');
}
return \Redirect::to('admin');
}
示例12: newCategory
public function newCategory()
{
$validate = new Validate();
$validated = $validate->Validate_Category();
$nameToSlug = $this->nameToSlug($validated);
if (\Auth::check()) {
if ($validated->passes() && $nameToSlug === true) {
$slug = \Input::get('name');
$slug = preg_replace('#[ -]+#', '-', $slug);
$slug = strtolower($slug);
\DB::beginTransaction();
try {
$item = new \MenuCategory();
$item->menu_category_name = \Input::get('name');
$item->menu_category_slug = $slug;
$item->save();
} catch (ValidationException $e) {
DB::rollback();
throw $e;
}
\DB::commit();
return \Redirect::to('admin/category/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved!</p></div>');
}
if ($nameToSlug === false) {
return \View::make('categories.new')->withErrors($validated)->withInput(array('name'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">That category already exists!');
}
return \View::make('categories.new')->withErrors($validated)->withInput(array('name'));
}
return \Redirect::to('admin');
}
示例13: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//dd($this->req);
try {
\DB::begintransaction();
$parent_id = empty($this->req['parent_id']) ? 0 : $this->req['parent_id'];
$file = '';
if (!empty($_FILES['feed_file']['tmp_name'])) {
$base_name = date('d_m_Y_') . md5($_FILES['feed_file']['name']) . rand(11111, 99999) . time();
$fl_name = $base_name . '.png';
$fl = file_get_contents($_FILES['feed_file']['tmp_name']);
\Image::make($fl)->save($this->path . $fl_name);
$file = $fl_name;
}
$feed = data_feedback::create(['title' => $this->req['feed_title'], 'ask' => $this->req['feed_ask'], 'link' => $this->req['feed_link'], 'parent_id' => $parent_id, 'file' => $file, 'id_karyawan' => \Me::data()->id_karyawan]);
$kode = \Format::code($feed->id_feedback);
$feed->kode = $kode;
$feed->save();
if ($parent_id > 0) {
$up = data_feedback::find($parent_id);
$up->notif = $up->notif + 1;
$up->save();
}
\Loguser::create('Megisi form feedback Kode. #' . $kode);
\DB::commit();
return ['label' => 'success', 'err' => 'Feedback berhasil terkirim dengan Kode. ' . $feed->kode];
} catch (\Exception $e) {
\DB::rollback();
if (file_exists($this->path . $file)) {
@unlink($this->path . $file);
}
return ['label' => 'danger', 'err' => $e->getMessage()];
}
}
示例14: updateRestaurantInfo
public function updateRestaurantInfo()
{
$user = \Auth::user();
$id = $user->user_id;
$restaurant = \Restaurant::all();
foreach ($restaurant as $rest) {
$restaurant_name = $rest->restaurant_name;
$restaurant_street_1 = $rest->restaurant_street_1;
$restaurant_street_2 = $rest->restaurant_street_2;
$restaurant_phone = $rest->restaurant_phone;
$restaurant_email = $rest->restaurant_email;
$restaurant_id = $rest->restaurant_info_id;
}
\DB::beginTransaction();
try {
$statement = \Restaurant::find($restaurant_id);
$statement->restaurant_name = \Input::get('name');
$statement->restaurant_street_1 = \Input::get('address1');
$statement->restaurant_street_2 = \Input::get('address2');
$statement->restaurant_email = \Input::get('email');
$statement->restaurant_phone = \Input::get('phone');
$statement->user_id_fk = $id;
$statement->save();
} catch (ValidationException $e) {
DB::rollback();
throw $e;
}
\DB::commit();
return \Redirect::to('admin/account/edit/restaurant')->withRestaurantName($restaurant_name)->withRestaurantStreet_1($restaurant_street_1)->withRestaurantStreet_2($restaurant_street_2)->withRestaurantPhone($restaurant_phone)->withRestaurantEmail($restaurant_email)->with('message', '<p class="alert alert-dismissible alert-success alert-link">Saved!' . '</p>');
}
示例15: postAdminSettings
public function postAdminSettings()
{
$title = Input::get('title');
$about = Input::get('about');
$address = Input::get('address');
$phone = Input::get('phone');
$email = Input::get('email');
$location = Input::get('location');
$file = Input::file('file');
$destinationPath = 'uploads';
$filename = DB::table('settings')->first()->logo;
// If the uploads fail due to file system, you can try doing public_path().'/uploads'
if ($file) {
$filename = time() . $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$upload_success = Input::file('file')->move($destinationPath, $filename);
}
DB::beginTransaction();
try {
DB::table('settings')->where('id', 1)->update(array('title' => $title, 'logo' => $filename, 'about' => $about, 'address' => $address, 'phone' => $phone, 'email' => $email, 'location' => $location));
DB::commit();
return Redirect::route('getAdminSettings')->with(array('status' => 'success'));
} catch (\Exception $e) {
DB::rollback();
return Redirect::route('getAdminSettings')->with(array('status' => 'error'));
}
}