| @@ 597-613 (lines=17) @@ | ||
| 594 | * |
|
| 595 | * @return bool <p>This will return true or false indicating success of transaction</p> |
|
| 596 | */ |
|
| 597 | public function beginTransaction(): bool |
|
| 598 | { |
|
| 599 | if ($this->_in_transaction === true) { |
|
| 600 | $this->_debug->displayError('Error: mysql server already in transaction!', false); |
|
| 601 | ||
| 602 | return false; |
|
| 603 | } |
|
| 604 | ||
| 605 | $this->clearErrors(); // needed for "$this->endTransaction()" |
|
| 606 | $this->_in_transaction = true; |
|
| 607 | $return = \mysqli_autocommit($this->link, false); |
|
| 608 | if ($return === false) { |
|
| 609 | $this->_in_transaction = false; |
|
| 610 | } |
|
| 611 | ||
| 612 | return $return; |
|
| 613 | } |
|
| 614 | ||
| 615 | /** |
|
| 616 | * Clear the errors in "_debug->_errors". |
|
| @@ 834-853 (lines=20) @@ | ||
| 831 | * |
|
| 832 | * @return bool <p>This will return true or false indicating success of transactions.</p> |
|
| 833 | */ |
|
| 834 | public function endTransaction(): bool |
|
| 835 | { |
|
| 836 | if ($this->_in_transaction === false) { |
|
| 837 | $this->_debug->displayError('Error: mysql server is not in transaction!', false); |
|
| 838 | ||
| 839 | return false; |
|
| 840 | } |
|
| 841 | ||
| 842 | if (!$this->errors()) { |
|
| 843 | $return = \mysqli_commit($this->link); |
|
| 844 | } else { |
|
| 845 | $this->rollback(); |
|
| 846 | $return = false; |
|
| 847 | } |
|
| 848 | ||
| 849 | \mysqli_autocommit($this->link, true); |
|
| 850 | $this->_in_transaction = false; |
|
| 851 | ||
| 852 | return $return; |
|
| 853 | } |
|
| 854 | ||
| 855 | /** |
|
| 856 | * Get all errors from "$this->_errors". |
|