Publishing System Settings Logout Login Register
MySQL Triggers - Automating Your Way To Happiness
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on November 24th, 2010
2094 views
MySQL

Automation Is Good

Much of what we do when writing web applications is overhead. A decent amount of code in any web application is going to be written out of sheer necessity because of a previous action. This extra code isn't productive, it's not enjoyable and each time you have to write it you open up the possibility to human error. Thankfully there are ways to severely limit the amount of impact this mundane overhead has.

Throughout this guide we're going to look at a specific scenario. We will address the issue and we'll solve it accordingly. We'll be doing our testing through whatever medium you're most comfortable with. I'm in my terminal, doing things from the command line. You may feel free to use phpMyAdmin if that's your choice.

The scenario: You run a site with a membership system. Articles posted to your site can be commented on; only members may comment. And naturally you won't to keep track of how many comments each user has. You can do this any number of ways but the two most common are:

Either count the comments table, looking for rows where the user ID of the comment is the same as the profile being viewed. Or store the number of comments the user has in the users table. I prefer the latter and it's what this guide is going to be written off. Number of comments is a detail belonging to the member, so it might as well be stored with the rest of their details in the user table.

Next Page
Pages: 1 2 3 4 5
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
Bobby Hensley

I'm Bobby Hensley, a 21 year old software engineer from the United States. My primary focuses are C++, Ruby and PHP.
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top