June 2017
Intermediate to advanced
536 pages
9h 49m
English
While the SELECT, INSERT, UPDATE, and DELETE methods allow us to manipulate data in a step-by-step manner, the real strength of MySQL lies in transactions. Using the begin_transaction(), commit(), commit(), and rollback() methods of an mysqli instance, we are able to control the transaction features of MySQL:
<?phpmysqli_report(MYSQLI_REPORT_ALL);$mysqli = new mysqli('127.0.0.1', 'root', 'mL08e!Tq', 'sakila');try { // Start new transaction $mysqli->begin_transaction(MYSQLI_TRANS_START_READ_WRITE); // Create new address $result = $mysqli->query('INSERT INTO address ( address, district, city_id, postal_code, phone ) VALUES ( "The street", "The district", 333, "31000", "123456789" ); '); // Fetch newly created address id $addressId ...
Read now
Unlock full access