Override the Query Methods

The simple solution to this problem is inheritance. On the surface, this would seem fairly straightforward: Create a class that extends SQLiteDatabase and override all the query methods. If errors arise within those overridden methods, simply throw an exception. In this way, the messy details of error trapping can be buried inside the class file and a single catch block can handle all errors. The first five methods in the class definition file shown in Listing 15-4 do exactly this.

Listing 15-4. Extending the SQLiteDatabase class
 ////////////////////////////////////////////////////////////// //public functions related to queries /** Override function */ public function query($strsql, $type = SQLITE_BOTH, &$err_msg ...

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.