Doing a roll back with multiple MySQLI prepared statement This is my code for doing a roll back with multiple MySQLI prepared statement.

I want to know if anything is wrong with the code.

 $newRegistrationDataArray = array(
    "date" =&gt; $date,
    "name" =&gt; $name,
    "address" =&gt; $address,
    "country" =&gt; $country,
    "occupation" =&gt; $occupation,
    "emailAddress" =&gt; $emailAddress,
    "memberID" =&gt; $memberID,
    "usename" =&gt; $usename,
    "password" =&gt; $password,
    "salt" =&gt; $salt,
    "secretQuestion" =&gt; $secretQuestion,
    "secretAnswer" =&gt; $secretAnswer,
    "transactionCode" =&gt; $transactionCode,
    "perfectMoneyAccount" =&gt; $perfectMoneyAccount,
    "egoPayAccount" =&gt; $egoPayAccount,
    "payeerAccount" =&gt; $payeerAccount,
    "okPayAccount" =&gt; $okPayAccount,
    "bitcoinAccount" =&gt; $bitcoinAccount,
    "upline" =&gt; $upline,
    "userRegistrationIp" =&gt; $userRegistrationIp,
    "status" =&gt; $status
);

public function CreateNewAccount(&amp;$newRegistrationDataArray){ ///note the &amp;

    /* set autocommit to off */
    $this-&gt;dbConnection-&gt;autocommit(FALSE);

    $stmt1=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `members` (date,name,address,country,occupation,emailAddress,memberID,usename,password,salt,secretQuestion,secretAnswer,transactionCode,perfectMoneyAccount,egoPayAccount,payeerAccount,okPayAccount,bitcoinAccount,upline,userRegistrationIp,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    $stmt2=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `membertotalfinancialstatus` (memberId) VALUES (?)");

    /* variable needed */
    $memberId = $this-&gt;generateMemberId(); // a private function that generate member id
    $date = $newRegistrationDataArray['date'];
    $name = $newRegistrationDataArray['name'];
    $address = $newRegistrationDataArray['address'];
    $country = $newRegistrationDataArray['country'];
    $occupation = $newRegistrationDataArray['occupation'];
    $emailAddress = $newRegistrationDataArray['emailAddress'];
    $usename = $newRegistrationDataArray['usename'];
    $password = $newRegistrationDataArray['password'];
    $salt = $newRegistrationDataArray['salt'];
    $secretQuestion = $newRegistrationDataArray['secretQuestion'];
    $secretAnswer = $newRegistrationDataArray['secretAnswer'];
    $transactionCode = $newRegistrationDataArray['transactionCode'];
    $perfectMoneyAccount = $newRegistrationDataArray['perfectMoneyAccount'];
    $egoPayAccount = $newRegistrationDataArray['egoPayAccount'];
    $payeerAccount = $newRegistrationDataArray['payeerAccount'];
    $okPayAccount = $newRegistrationDataArray['okPayAccount'];
    $bitcoinAccount = $newRegistrationDataArray['bitcoinAccount'];
    $upline = $newRegistrationDataArray['upline'];
    $userRegistrationIp = $newRegistrationDataArray['userRegistrationIp'];
    $status = $newRegistrationDataArray['status'];
    /* variable needed */

    $stmt1-&gt;bind_param('sssssssssssssssssssss',$date,$name,$address,$country,$occupation,$emailAddress,$memberID,$usename,$password,$salt,$secretQuestion,$secretAnswer,$transactionCode,$perfectMoneyAccount,$egoPayAccount,$payeerAccount,$okPayAccount,$bitcoinAccount,$upline,$userRegistrationIp,$status);
    $stmt2-&gt;bind_param('s',$memberId);

    try
    {
        if( ($stmt1-&gt;execute() == false) OR ($stmt2-&gt;execute() == false)){

            /// close statement, roll back and throw an exception
            $stmt1-&gt;close();
            $stmt2-&gt;close();

            $this-&gt;dbConnection-&gt;rollback();
            throw new Exception("AN INTERNAL ERROR HAS OCCURED. TRY AGAIN LATER.");
        }
    }
    catch(Exception $e)
    {
        $error=$e-&gt;getMessage();
        throw new Exception($error);    
    }

    $this-&gt;closeDBConn;
}
function CreateNewAccount(&amp;$newRegistrationDataArray){ ///note the &amp;


    /* variable needed */
    $memberId = $this-&gt;generateMemberId(); // a private function that generate member id

    // that is lots of repetitive code, lazy way is use extract,
    // although can be dangerous if you can't trust data in $newRegistrationDataArray
    extract($newRegistrationDataArray);

//    $date = $newRegistrationDataArray['date'];
//    $name = $newRegistrationDataArray['name'];
//    $address = $newRegistrationDataArray['address'];
//    $country = $newRegistrationDataArray['country'];
//    $occupation = $newRegistrationDataArray['occupation'];
//    $emailAddress = $newRegistrationDataArray['emailAddress'];
//    $usename = $newRegistrationDataArray['usename'];
//    $password = $newRegistrationDataArray['password'];
//    $salt = $newRegistrationDataArray['salt'];
//    $secretQuestion = $newRegistrationDataArray['secretQuestion'];
//    $secretAnswer = $newRegistrationDataArray['secretAnswer'];
//    $transactionCode = $newRegistrationDataArray['transactionCode'];
//    $perfectMoneyAccount = $newRegistrationDataArray['perfectMoneyAccount'];
//    $egoPayAccount = $newRegistrationDataArray['egoPayAccount'];
//    $payeerAccount = $newRegistrationDataArray['payeerAccount'];
//    $okPayAccount = $newRegistrationDataArray['okPayAccount'];
//    $bitcoinAccount = $newRegistrationDataArray['bitcoinAccount'];
//    $upline = $newRegistrationDataArray['upline'];
//    $userRegistrationIp = $newRegistrationDataArray['userRegistrationIp'];
//    $status = $newRegistrationDataArray['status'];
    /* variable needed */


    try
    {
        /* set autocommit to off */
        $this-&gt;dbConnection-&gt;autocommit(FALSE);

        $stmt1=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `members` (date,name,address,country,occupation,emailAddress,memberID,usename,password,salt,secretQuestion,secretAnswer,transactionCode,perfectMoneyAccount,egoPayAccount,payeerAccount,okPayAccount,bitcoinAccount,upline,userRegistrationIp,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        $stmt1-&gt;bind_param('sssssssssssssssssssss',$date,$name,$address,$country,$occupation,$emailAddress,$memberID,$usename,$password,$salt,$secretQuestion,$secretAnswer,$transactionCode,$perfectMoneyAccount,$egoPayAccount,$payeerAccount,$okPayAccount,$bitcoinAccount,$upline,$userRegistrationIp,$status);

        // failure is unexpected, so lets use exceptions to handle it
        if ($stmt1-&gt;execute() == false) {
            throw new Exception('Statement 1 Failed');
        }

        $stmt2=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `membertotalfinancialstatus` (memberId) VALUES (?)");
        $stmt2-&gt;bind_param('s',$memberId);

        if ($stmt2-&gt;execute() == false) {
            throw new Exception('Statement 2 Failed');
        }

        // tidy up
        $stmt1-&gt;close();
        $stmt2-&gt;close();

        // is it normal to close connection at this level? or do you leave it open for other requests
        $this-&gt;closeDBConn;
    }
    catch(Exception $e)
    {
        // any sort of exception and we should rollback?
        // either that or subclass exception and handle each exception type differently
        $this-&gt;dbConnection-&gt;rollback();

        // whats the point of this, just re-throw the same exception?
        // $error=$e-&gt;getMessage();
        // throw new Exception($error);
        throw $e;
    } finally {
       // if you have php 5.5 you can do your tidy up here, although if 
       // an exception has occured, you probably don't care about freeing stmt's as
       // they all end up in the garbage anyway

        // tidy up
        //$stmt1-&gt;close();
        //$stmt2-&gt;close();
    }

}