-
mysqli कनेक्ट करने से पहले इस लाइन को जोड़कर mysqli को अपवाद मोड में रखें
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
- अपनी क्वेरी को लेन-देन में लपेटें
- अपने लेन-देन को try..catch कथन में लपेटें और अंदर एक रोलबैक कॉल जोड़ें।
तो कोड कुछ इस तरह होगा
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$db = new mysqli(...);
...
try {
$db->autocommit(FALSE);
$db->address_table_insert_statement($firstName, $lastName, $companyName, $streetAddress, $streetAddress2, $streetAddress3, $city, $state, $zip, $country, $phone, $fax, $email, $date, $date);
$addressId = mysqli_insert_id($db->connection);
$db->address_table_insert_statement($firstName, $lastName, $companyName, $billingStreetAddress, $billingStreetAddress2, $billingStreetAddress3, $billingCity, $billingState, $billingZipCode, $billingCountry, $billingPhone, $billingFax, $billingEmail, $date, $date);
$billingAdressId = mysqli_insert_id($db->connection);
$db->account_table_insert_statement($active, $addressId, $billingAddressId, $dateCreated, $dateModified);
$db->commit();
} catch (\Exception $e) {
$db->rollback();
throw $e;
}