Changes to the MySQLConnect Class

The changes required so that the MySQLConnect class can use MySQLException objects are minimal. Of course the MySQLConnect class needs to know about this derived exception class, but this is easily accomplished with the following statement:

require 'MySQLException.php';

Next, you need an error code number that is greater than or equal to 5,000 (that is, outside the range used by MySQL). Then define a constant class value using the keyword const and give this constant a name using uppercase letters (per convention). The const keyword performs the same task for OOP as the define function does for procedural programming—it declares a variable that cannot be changed. Constant data members do not use access modifiers, ...

Get Object-Oriented PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.