Firebird Documentation IndexFirebird 3.0 Developer's GuideDeveloping Web Applications with PHP and Firebird → Transactions
Firebird Home Firebird Home Prev: Creating ModelsFirebird Documentation IndexUp: Developing Web Applications with PHP and FirebirdNext: Creating Controllers and Configuring Routing

Transactions

Now let us talk a little about transactions. Without going into the fine detail, I will demonstrate how transactions and the Eloquent ORM can be used together.

DB::transaction(function () {
  // Create a new position in the invoice
  $line = new App\InvoiceLine();
  $line->CUSTOMER_ID = 45;
  $line->PRODUCT_ID = 342;
  $line->QUANTITY = 10;
  $line->COST = 12.45;
  $line->save();
  // add the sum of the line item to the amount of the invoice
  $invoice = App\Invoice::find($line->CUSTOMER_ID);
  $invoice->INVOICE_SUM += $line->SUM_PRICE;
  $invoice->save();
});
      

Every parameter of the transaction method that is located inside the callback function is executed within one transaction.

Prev: Creating ModelsFirebird Documentation IndexUp: Developing Web Applications with PHP and FirebirdNext: Creating Controllers and Configuring Routing
Firebird Documentation IndexFirebird 3.0 Developer's GuideDeveloping Web Applications with PHP and Firebird → Transactions