| @@ 573-588 (lines=16) @@ | ||
| 570 | * |
|
| 571 | * @return bool <p>This will return true or false indicating success of transaction</p> |
|
| 572 | */ |
|
| 573 | public function beginTransaction(): bool |
|
| 574 | { |
|
| 575 | if ($this->_in_transaction === true) { |
|
| 576 | $this->_debug->displayError('Error: mysql server already in transaction!', false); |
|
| 577 | ||
| 578 | return false; |
|
| 579 | } |
|
| 580 | ||
| 581 | $this->clearErrors(); // needed for "$this->endTransaction()" |
|
| 582 | $this->_in_transaction = true; |
|
| 583 | $return = \mysqli_autocommit($this->link, false); |
|
| 584 | if ($return === false) { |
|
| 585 | $this->_in_transaction = false; |
|
| 586 | } |
|
| 587 | ||
| 588 | return $return; |
|
| 589 | } |
|
| 590 | ||
| 591 | /** |
|
| @@ 769-787 (lines=19) @@ | ||
| 766 | * |
|
| 767 | * @return bool <p>This will return true or false indicating success of transactions.</p> |
|
| 768 | */ |
|
| 769 | public function endTransaction(): bool |
|
| 770 | { |
|
| 771 | if ($this->_in_transaction === false) { |
|
| 772 | $this->_debug->displayError('Error: mysql server is not in transaction!', false); |
|
| 773 | ||
| 774 | return false; |
|
| 775 | } |
|
| 776 | ||
| 777 | if (!$this->errors()) { |
|
| 778 | $return = \mysqli_commit($this->link); |
|
| 779 | } else { |
|
| 780 | $this->rollback(); |
|
| 781 | $return = false; |
|
| 782 | } |
|
| 783 | ||
| 784 | \mysqli_autocommit($this->link, true); |
|
| 785 | $this->_in_transaction = false; |
|
| 786 | ||
| 787 | return $return; |
|
| 788 | } |
|
| 789 | ||
| 790 | /** |
|