Posted on Leave a comment

Debug code better, faster and with fewer headaches

Every time you change code, there’s a very good chance that you will have introduced bugs to your existing code. IT’s important to take a methodical approach to squishing these bugs, or you may waste a lot of time hunting down the cause of specific problems. Here are 7 tips to debugging your code faster.

debugging php javascript c++ java

  1. Don’t pretend that this isn’t your fault (or your teams fault). You wrote the code and you made a mistake. Don’t beat yourself up over it, but don’t blame the computer for your mistake. By that same token, dont’ beat yourself up over a bug. Bugs will always happen, just solve it and move on.
  2. Treat every error as an opportunity to learn about yourself. If you think of bugs as a puzzle or mystery to be solved, you won’t find yourself burning out as fast and this will encourage a more patient and relaxed approach to solving errors.
  3. Write tests. Testing is not only great at preventing bugs but also helps a lot in debugging. Testing forces your design to be more or less modular, which makes isolating and replicating problems simpler. The tighter control this provides over the environment will cause fewer surprises. Moreover, once you get a failing test case, you can be reasonably sure that you’ve caught the real reason of the code’s behaviour..
  4. Use a debugger! Don’t avoid stepping through your code with a debugger just because it’s time consuming. Checking every line of your logic will often help you to find better ways to do things and highlight the real cause of errors. I personally really like the built in debuggers in both Netbeans and PHPStorm
  5. Talk about someone about your problem, even if it’s just a rubber duck (I personally use my android figurines from Android TO). Forcing yourself to express the problem you are working on in words really does miracles.
  6. Give yourself a time limit. If for example after 45 minutes you feel you are going nowhere, just switch to other tasks for some time. When you get back to your bug, you’ll hopefully be able to see other possible solutions that you wouldn’t have have considered before.
  7. If you have narrowed it down to two systems that collaborate (for example a PHP back-end and a JavaScript front-end), inspect the messages between the two systems via traffic monitor or log files, and determine which system is behaving correctly and which one is not. If there are more than two systems in the scenario, you can perform pairwise checks and work your way “down” the application stack.

As you can see, debugging code isn’t always an exact science,but by applying the right mindset and techniques, you can speed up the process significantly. Fast debugging isn’t always

Related reading:
Why Programs Fail
The Pragmatic Programmer
Software Entrophy

Posted on Leave a comment

Factory Design Pattern In PHP


( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.417613533344CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.423213545216CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.417613533344CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.423213545216CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.429413651216CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.430513583736CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.429413651216CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.430513583736CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.436013648752CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.438413597848CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.436013648752CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.438413597848CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.444613671056CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.445713599896CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.400313375200get_template_part( ).../loop.php:21
100.400313375616locate_template( ).../general-template.php:168
110.400413375696load_template( ).../template.php:671
120.400513375944require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.402013375944do_action( ).../content.php:19
140.402013376320WP_Hook->do_action( ).../plugin.php:478
150.402013376320WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.405313376696storefront_post_content( ).../class-wp-hook.php:288
170.406513376992the_content( ).../storefront-template-functions.php:414
180.406513379040apply_filters( ).../post-template.php:253
190.406513379440WP_Hook->apply_filters( ).../plugin.php:206
200.411813388824CrayonWP::the_content( ).../class-wp-hook.php:288
210.444613671056CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.445713599896CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

The factory design pattern solves a common programming problem. When you have a single point of origin for many classes with the same base class, you have need of the factory design pattern. A factory is a class that instantiates one or more of a number of classes that share the same base type, choosing the type of the instantiated object type at runtime without exposing the instantiation logic. You won’t often see this pattern appearing in basic projects, but as you move into enterprise development, it is very common.

In the following example, an object of type ShapeFactory is instantiated by the application code. Then when the getShape() method is called, the ShapeFactory object instantiates a new object which based on the logic in this function chooses which child class of the Shape class will be chosen to hold the new object. This allows a little more freedom in which types we use at runtime.

Factory Design Pattern UML Diagram
Basic Factory Design Pattern UML Diagram

Factory Design Pattern Example In PHP

The factory design pattern is very simple. The simplest example I like to use to describe it using PHP is a basic game with different kinds of enemy ships. In the following example we will start with an enemy class, and a few child classes that extend it like so:

Now if we are playing a game and wanted to call any of the enemy ship types from a single point of origin, we would spawn them using a factory class that looks something like this:

The code that calls the factory looks like this:

With output looking like this:

Posted on Leave a comment

Lean and Mean PHP Email Class


( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.452113537160get_template_part( ).../loop.php:21
100.452113537576locate_template( ).../general-template.php:168
110.452213537656load_template( ).../template.php:671
120.452213537904require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.453813537904do_action( ).../content.php:19
140.453813538280WP_Hook->do_action( ).../plugin.php:478
150.453813538280WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.457513538656storefront_post_content( ).../class-wp-hook.php:288
170.457613538976the_content( ).../storefront-template-functions.php:414
180.457713539232apply_filters( ).../post-template.php:253
190.457713539632WP_Hook->apply_filters( ).../plugin.php:206
200.462713543888CrayonWP::the_content( ).../class-wp-hook.php:288
210.466713612008CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.474513575152CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.452113537160get_template_part( ).../loop.php:21
100.452113537576locate_template( ).../general-template.php:168
110.452213537656load_template( ).../template.php:671
120.452213537904require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.453813537904do_action( ).../content.php:19
140.453813538280WP_Hook->do_action( ).../plugin.php:478
150.453813538280WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.457513538656storefront_post_content( ).../class-wp-hook.php:288
170.457613538976the_content( ).../storefront-template-functions.php:414
180.457713539232apply_filters( ).../post-template.php:253
190.457713539632WP_Hook->apply_filters( ).../plugin.php:206
200.462713543888CrayonWP::the_content( ).../class-wp-hook.php:288
210.466713612008CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.474513575152CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

Sending beautiful emails and attaching files with PHP can be a real hassle. I wrote this class as part of one of my side projects but I have recently used it as a teaching tool.

 

Posted on Leave a comment

Simple & Light PHP MySql Db Class


( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.480313565432get_template_part( ).../loop.php:21
100.480313565848locate_template( ).../general-template.php:168
110.480413565928load_template( ).../template.php:671
120.480413566176require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.481813566176do_action( ).../content.php:19
140.481813566552WP_Hook->do_action( ).../plugin.php:478
150.481813566552WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.485313566928storefront_post_content( ).../class-wp-hook.php:288
170.485413567248the_content( ).../storefront-template-functions.php:414
180.485413567888apply_filters( ).../post-template.php:253
190.485413568288WP_Hook->apply_filters( ).../plugin.php:206
200.490313573568CrayonWP::the_content( ).../class-wp-hook.php:288
210.494213638800CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.499813572760CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0001395848{main}( ).../index.php:0
20.0002396136require( '/var/www/html/wp-blog-header.php' ).../index.php:17
30.280812787304require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.288212916680include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
50.375813328368get_template_part( ).../archive.php:25
60.375913328832locate_template( ).../general-template.php:168
70.375913328912load_template( ).../template.php:671
80.376013329200require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
90.480313565432get_template_part( ).../loop.php:21
100.480313565848locate_template( ).../general-template.php:168
110.480413565928load_template( ).../template.php:671
120.480413566176require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
130.481813566176do_action( ).../content.php:19
140.481813566552WP_Hook->do_action( ).../plugin.php:478
150.481813566552WP_Hook->apply_filters( ).../class-wp-hook.php:312
160.485313566928storefront_post_content( ).../class-wp-hook.php:288
170.485413567248the_content( ).../storefront-template-functions.php:414
180.485413567888apply_filters( ).../post-template.php:253
190.485413568288WP_Hook->apply_filters( ).../plugin.php:206
200.490313573568CrayonWP::the_content( ).../class-wp-hook.php:288
210.494213638800CrayonHighlighter->output( ).../crayon_wp.class.php:703
220.499813572760CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

In my world, a PHP db class in essence should be a black box that handles the concerns of direct interaction with the MySql database and provides an abstract but functional alone basis for my model classes. The Db class must handle connecting to the database, and have inheritable static methods for executing both statements and queries. Also it must be tested before it is put into production. This code is tested and ready for production.

I originally wrote this class in a side-project of mine, and I’ve been using it recently as a teaching tool.