2010/11 : [1]Building Web Applications using MySQL and PHP (W1)Application Error Handling.

Slides:



Advertisements
Similar presentations
Lectures on File Management
Advertisements

Transaction Processing. Objectives After completing this lesson, you should be able to do the following: –Define transactions effectively for an application.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
Transaction Processing IS698 Min Song. 2 What is a Transaction?  When an event in the real world changes the state of the enterprise, a transaction is.
Database Management Systems I Alex Coman, Winter 2006
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
Managing Concurrency in Web Applications. DBI 2007 HUJI-CS 2 Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses.
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
Transactions and Recovery
ABSTRACT Before the evolution of computers, all the details in a banking systems used to be maintained manually. This is not advisable because maintenance.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
1 CSE 480: Database Systems Lecture 23: Transaction Processing and Database Recovery.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Failsafe systems Fail by Failing to be Failsafe. Or to put it simply Don’t worry, nothing can go wrong click go wrong click go wrong click.
PHP meets MySQL.
Checking Accounts. What is a checking account? A bank account that allows easy access to the funds. You can use your checking account to pay bills. With.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
Transactions1 Unit of work on a database. Transactions2 Transactions, concept Logical unit of work on the database –Examples Transfer money from bank.
TRANSACTIONS. Objectives Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction.
1cs Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses by multiple users Concurrent accesses intersect.
Transaction Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
HANDLING FAILURES. Warning This is a first draft I welcome your corrections.
Chapter 9 Selecting, Updating, and Deleting Data Syed Rizvi.
Transaction processing Book, chapter 6.6. Problem: With a single user…. you run a query, you get the results, you run the next, etc. But database life.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
IT Essentials: PC Hardware and Software v4.0. Chapter 4 Objectives 4.1 Explain the purpose of preventive maintenance 4.2 Identify the steps of the troubleshooting.
Introduction to Database Systems. RHS – Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
Transactions and Locks A Quick Reference and Summary BIT 275.
CS640 Information Systems Dr Deepak B Phatak Subrao Nilekani Chair Professor Kanwal Rekhi Building, Department of CSE IIT Bombay Session 7, SQL DML and.
INFO1408 Database Design Concepts Week 16: Introduction to Database Management Systems Continued.
Handling Exceptions. 2 home back first prev next last What Will I Learn? Describe several advantages of including exception handling code in PL/SQL Describe.
The Relational Model1 Transaction Processing Units of Work.
SQL ACTION QUERIES AND TRANSACTION CONTROL CS 260 Database Systems.
15.1 Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction to transfer.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts - 6 th Edition Chapter 14: Transactions Transaction Concept Transaction State Concurrent.
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
CSC 370 – Database Systems Introduction Instructor: Alex Thomo.
Chapter 15: Reliability and Security in Database Servers Neyha Amar CS 157B May 6, 2008.
Transactions.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Transactions.
Transaction Processing Concepts Muheet Ahmed Butt.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Instructor: Craig Duckett Lecture 07: Tuesday, October 20 th, 2015 Conflicts and Isolation, MySQL Workbench 1 BIT275: Database Design (Fall 2015)
Advanced Database CS-426 Week 6 – Transaction. Transactions and Recovery Transactions A transaction is an action, or a series of actions, carried out.
Unit-8 Introduction Of MySql. Types of table in PHP MySQL supports various of table types or storage engines to allow you to optimize your database. The.
Basic Web Application Development Instructor: Matthew Schurr.
Split your database Store temporary tables in a backend Don't use memo fields Create temporary tables to speed up queries Don't put Mac and Windows users.
How to fix Error code 0x80072ee2 in Windows 8.1? Fix%20%20Update%20Error%200x80072EE2%20in%20Windows%20 8.1,%20Windows%2010!%20-%20Fix%20PC%20Errors.htm.
Delete Data Database Administration Fundamentals LESSON 3.4.
UML Review Sequence Diagrams SE-2030 Dr. Rob Hasker 1 Based on slides written by Dr. Mark L. Hornick Used with permission.
COMP 430 Intro. to Database Systems Transactions, concurrency, & ACID.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Quicken customer service phone number One of the top financing software that is accessed by millions of users across the world the quicken.
Cosc 5/4765 Database security. Database Databases have moved from internal use only to externally accessible. –Organizations store vast quantities of.
Fundamental of Databases
Web Technologies IT230 Dr Mohamed Habib.
Database System Concepts and Architecture
Quicken Contact Phone Number This is not a common error that users face frequently, but sometimes it does pops up on the screen. If you are getting this.
On transactions, and Atomic Operations
Fundamentals of Databases
On transactions, and Atomic Operations
Instructor: Craig Duckett
About us Gmail is a famous service which we use on a daily basis for sending s, getting promotional messages of certain products, receiving.
MySQL Web Application Connecting to a MySQL database
Lab 8: GUI testing Software Testing LTAT
Presentation transcript:

2010/11 : [1]Building Web Applications using MySQL and PHP (W1)Application Error Handling

2010/11 : [2]Building Web Applications using MySQL and PHP (W1)Application Error Handling ‘Application’..? An ‘application’ in this case is any user interactive interface powered by PHP and MySQL. In this course, we concentrate on XHTML web interfaces. Although you have the technical knowledge of PHP and MySQL, there are a number of issues in a web environment that we haven’t discussed.

2010/11 : [3]Building Web Applications using MySQL and PHP (W1)Application Error Handling Failure is Inevitable. The world is a fallible place. Networks fail. Databases crash. Web servers get misconfigured. Robust applications are built with failure in mind. These slides are about handling web application failure when using PHP & MySQL.

2010/11 : [4]Building Web Applications using MySQL and PHP (W1)Application Error Handling Types of Error Handling On a desktop application, complicated error handling logic is required to prevent corruption of the application ‘state’ by unexpected failure. Such error handling can be undertaken by a web app too. However.. Web apps don’t persist much application state, so ‘Get the Hell outta there!’ error handling is often preferred.

2010/11 : [5]Building Web Applications using MySQL and PHP (W1)Application Error Handling Get the Hell Outta There! Simply exit the application (apologising to the the user) if an error occurs. $link = mysqli_connect(…); /* exit if can’t contact database */ if (mysqli_connect_errno()) { exit(‘Please try again later.’); }

2010/11 : [6]Building Web Applications using MySQL and PHP (W1)Application Error Handling Failure Points..? Some obvious failure points can be identified, usually associated with external resources: database connection, query failure. What is less obvious is that some sort of hardware fault/power problem might stop your script processing at any mid-way point.

2010/11 : [7]Building Web Applications using MySQL and PHP (W1)Application Error Handling Protect the Database. Your database is your one persistent store of information. Protect it at all costs. You need to make sure that any failure cannot corrupt the data in your database. The sort of corruption that can occur is best illustrated by an example.

2010/11 : [8]Building Web Applications using MySQL and PHP (W1)Application Error Handling Bank Transfer Example Si owes Rob £100, so transfers it across.. -- get si's balance SELECT balance FROM accounts WHERE name='si'; -- check its > 100, if so -- continue by deducting -- amount from si's account UPDATE accounts SET balance = balance-100 WHERE name='Si'; -- credit the money to rob UPDATE accounts SET balance = balance+100 WHERE name='Rob'; SELECT * FROM accounts; | name | balance | | rob | | | si | |

2010/11 : [9]Building Web Applications using MySQL and PHP (W1)Application Error Handling Corruption? Say for some reason the last query (to credit Rob’s account) failed.. No money would have reached Rob’s account, but the money would still have been deducted from Si’s account! Money has disappeared. Ooops. In other words, a failure has corrupted our database.

2010/11 : [10]Building Web Applications using MySQL and PHP (W1)Application Error Handling Transactions Often a sequence of queries need to be executed in a particular order, and if one query fails the whole lot fails. In other words, the queries need to be grouped. The classic example is that of a bank transaction.

2010/11 : [11]Building Web Applications using MySQL and PHP (W1)Application Error Handling MySQL Transaction Syntax Start transaction group: START TRANSACTION; Finish transaction and ‘save’ changes: COMMIT; Finish transaction and ‘undo’ everything: ROLLBACK;

2010/11 : [12]Building Web Applications using MySQL and PHP (W1)Application Error Handling Transactions and Table Type MySQL actually has a number of different table types. ( ( To use transactions, we need to use the InnoDB table type (it is not the default). CREATE TABLE accounts ( name VARCHAR(255), balance DECIMAL(10,2) ) ENGINE=InnoDB;

2010/11 : [13]Building Web Applications using MySQL and PHP (W1)Application Error Handling Transaction Example Back to the transfer of money.. we now enclose the queries in a transaction. If a query fails, we can explicitly undo everything ourselves using ROLLBACK. START TRANSACTION; SELECT balance FROM accounts WHERE name='si'; UPDATE accounts SET balance = balance-100 WHERE name='Si'; UPDATE accounts SET balance = balance+100 WHERE name='Rob'; COMMIT; or ROLLBACK;

2010/11 : [14]Building Web Applications using MySQL and PHP (W1)Application Error Handling Transactions with mysqli Start transaction group: mysqli_query($link,‘START TRANSACTION’); Finish transaction and ‘save’ changes: mysqli_commit($link); Finish transaction and ‘undo’ everything: mysqli_rollback($link);

2010/11 : [15]Building Web Applications using MySQL and PHP (W1)Application Error Handling Exercise Hands On Exercise: Application Error Handling

2010/11 : [16]Building Web Applications using MySQL and PHP (W1)Application Error Handling Review Introduced the awareness that failures need to be considered. Within PHP, the best option for serious errors is often a ‘give up and quit’ approach. The most important consideration is protecting the database. Transactions can be used to achieve this.