| @@ 479-494 (lines=16) @@ | ||
| 476 | * |
|
| 477 | * @return bool <p>This will return true or false indicating success of transaction</p> |
|
| 478 | */ |
|
| 479 | public function beginTransaction() |
|
| 480 | { |
|
| 481 | if ($this->_in_transaction === true) { |
|
| 482 | $this->_debug->displayError('Error: mysql server already in transaction!', false); |
|
| 483 | return false; |
|
| 484 | } |
|
| 485 | ||
| 486 | $this->clearErrors(); // needed for "$this->endTransaction()" |
|
| 487 | $this->_in_transaction = true; |
|
| 488 | $return = \mysqli_autocommit($this->link, false); |
|
| 489 | if ($return === false) { |
|
| 490 | $this->_in_transaction = false; |
|
| 491 | } |
|
| 492 | ||
| 493 | return $return; |
|
| 494 | } |
|
| 495 | ||
| 496 | ||
| 497 | /** |
|
| @@ 650-668 (lines=19) @@ | ||
| 647 | * |
|
| 648 | * @return bool <p>This will return true or false indicating success of transactions.</p> |
|
| 649 | */ |
|
| 650 | public function endTransaction() |
|
| 651 | { |
|
| 652 | if ($this->_in_transaction === false) { |
|
| 653 | $this->_debug->displayError('Error: mysql server is not in transaction!', false); |
|
| 654 | return false; |
|
| 655 | } |
|
| 656 | ||
| 657 | if (!$this->errors()) { |
|
| 658 | $return = \mysqli_commit($this->link); |
|
| 659 | } else { |
|
| 660 | $this->rollback(); |
|
| 661 | $return = false; |
|
| 662 | } |
|
| 663 | ||
| 664 | \mysqli_autocommit($this->link, true); |
|
| 665 | $this->_in_transaction = false; |
|
| 666 | ||
| 667 | return $return; |
|
| 668 | } |
|
| 669 | ||
| 670 | /** |
|
| 671 | * Get all errors from "$this->_errors". |
|