Blog

  • CakePHP Extending one View from Another


    A new feature in CakePHP 2.1 is the ability to make one view extend another view.  This is a very neat feature; it’s actually quite similar to the concept of Jquery template.  The concept behind it is relatively straight forward.  You define one view that contains common elements that will be updated in another view.  The goal is to avoid duplicating the HTML in a different view.

    (more…)

  • The Best Way to Prevent SQL Injection

    If you use a framework of some sort, you probably haven’t thought about SQL injection for some time – in fact it almost seems dated to even discuss it.  However, security should never be overlooked and it’s important to not trust third party applications and people by default!  So what is the best way to prevent SQL injection?

    Have you noticed how I haven’t specified a specific language?  This is done purposely, because at the end of the day – all languages – should be able to follow this paradigm…

    (more…)

  • CakePHP 2.x Login System

    Well, since one of my most popular all-time blog posts is Login system with CakePHP in under 10 minutes I think it’s time that I update it to version 2.x (currently 2.2 at the time of writing).  The original post was probably written for version 1.2 or 1.1 and there have been several changes made, especially with breaking changes to the AuthenicateComponent.

    The beautiful part is the changes are extremely limited.  In fact, only the UsersController requires a few minor changes.

    (more…)

  • Load Testing Mysql with mysqlslap

    I have a few thoughts for some testing/comparison of mysql tables that I have been curious about.  Before starting though, I thought it was prudent that I should give it some thought about the approach.  The first thing that came to mind was altering the A Simple But Effective Speed Comparison code to execute a bunch of SQL queries against my local installation.

    I really didn’t like this approach because of the potential inaccuracy due to the overhead of the language and connecting to mysql before executing the queries.  The whole purpose of these potential upcoming articles is to compare mysql, not a specific language integrating with mysql.

    Luckily for us, as of Mysql 5.1.4, a tool called mysqlslap is shipped with the server installation.  This tool allows us to client emulation against our mysql server!

    (more…)

  • Update: It Actually Should Be LEPP Not LEMP or LAMP!

    In several recent posts: It’s LEMP not LAMP! and Amazon EC2 Shoutout! I’ve discussed how I switched from a shared hosting account with GoDaddy to a dedicated Micro instance with Amazon.  At the same time I decided to go out and try nginx (pronounced Engine-X) and remove Apache from the equation.

    This saw some incredible results.  However, several times since switching I’ve run into several database issues where it appears Mysql runs out of memory!  Performing a top command shows over 15 mysql processes running at anyone giving time each taking up to 10% of the memory.  On a micro instance I only get 600mb, so this adds up quickly!

    (more…)