410 Part IV . Development Handling errors with

410 Part IV . Development Handling errors with the DBI In most instances, error handling is automatic with the DBI. This was evidenced by earlier Figures and examples in this chapter. The error messages look quite similar to those you would see with other MySQL tools such as the CLI or mysqladmin. Sometimes you may want to disable this automatic error-checking in favor of manual error checking (or a combination of automatic and manual). Error handling is configured using the attributes or elements discussed in a previous section. There are two attributes of DBI error-checking: PrintError and RaiseError. By default, PrintError is enabled. PrintError simply prints the error message to the screen and continues execution of the program as if nothing had happened. This is bad if your program is relying on information from the database and a statement or command fails to execute. To illustrate this behavior, take a look at the program in Figure 15-20. In this program, I query a database for a number and then perform a computation based on that number. I allow PrintError to perform the error checking in the program, but do no further error handling myself. You can see the results of the program in action in Figure 15-20 as well. The program happily continues, even though the query execution failed. If these results were to be automatically e-mailed to me using a scheduling program such as cron, I wouldn t see these error messages. Figure 15-20: A program continues execution in the event of an error when using the default PrintError for error-checking.
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Leave a Reply