A MySQL “tinyint” field, regardless of length, is mapped as a boolean in Symfony’s MySQL DBAL platform.  Good to know, so when you start typing in those Doctrine ORM mapping files in annotation or my preferred way, YML files, you won’t get a fatal error because you didn’t define the field properly.

Here’s a list of the other main MySQL field types and how they are defined in Doctrine ORM mapping files.  It can get a little confusing, like “timestamp” is also “datetime” even though “datetime” is “datetime”.  It is what it is.  Once you realize you’re just making translations for one system to talk to another, it gets easier!

This list is helpful because when you start converting your database table fields, you will need a reference, or better yet, look into “Skipper ORM” and it will take care of mappings and creating entities out of your database tables automatically for you!

protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = array(
'tinyint' => 'boolean',
'smallint' => 'smallint',
'mediumint' => 'integer',
'int' => 'integer',
'integer' => 'integer',
'bigint' => 'bigint',
'tinytext' => 'text',
'mediumtext' => 'text',
'longtext' => 'text',
'text' => 'text',
'varchar' => 'string',
'string' => 'string',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'timestamp' => 'datetime',
'time' => 'time',
'float' => 'float',
'double' => 'float',
'real' => 'float',
'decimal' => 'decimal',
'numeric' => 'decimal',
'year' => 'date',
'longblob' => 'blob',
'blob' => 'blob',
'mediumblob' => 'blob',
'tinyblob' => 'blob',
'binary' => 'blob',
'varbinary' => 'blob',
'set' => 'simple_array',
);
}

 


In the newest versions of Symfony greater than 2.2 you can embed output from controller by calling it with this handy TWIG snippet:

{{ render(controller('PostBundle:Posts:recentPosts', { 'category': 'cool symfony tips' })) }}

Check out Sensio Lab’s documentation to learn more.

This is especially useful if you want to create a snippet that will deliver content independent of the controller you are calling the main content of the page — stuff around the periphery.  As long as you aren’t using any logic, this is an acceptable use of MVC and it decouples say content in a related widget on the page from the controller of the page’s main content.  This separation of concerns ensures the controller of the main content stays as lean and clean as possible!


All organizations need to be prepared for potential business interruptions. They need to have fall back plans in case of disaster and system failures. The integrity of a company’s data systems is paramount to minimizing the cost incurred from business interruptions.

Threat Response Matrix

Does your business plan have a “Threat Response Matrix”? In its simplest form, list the different “worst case” scenarios for your business. You need to be pragmatic and explore the potential horrors that could unfold and beseech your company. Questions and scenarios like:

  • What will we lose if there is a fire, flood, storm damage or break-in?
    • How will we restore operations and data as fast as possible?
  • What will we need to do if power goes out for more than 4 hours?
    • How will we respond to inbound phone calls and how will we continue outbound communication?
  • If our main internet connection is down, how will we divert to a fallback connection?
  • What will we need to do if a vital computer and/or hard drive no longer works?
  • What will we do if our websites or internal networks get hacked or customer data stolen?
    • What safeguards can we put in place to not just be PCI compliant, but be even more stringent with our sensitive data?

After you list your potential threats, you need to rank these business operational threats by how likely they will occur. From the above list of potential threats, I have experienced them all, but the one that occurred most unexpectedly and more frequently than any other was hard drive failure.

Hard drives are the weakest link

The most common cause of partial or total business interruption is hard drive failure.

Hard drives can fail at anytime and seemingly for no reason, they can intentionally get corrupt by certain viruses as well. It doesn’t take physical damage from an obvious event, like someone dropping a hard drive or laptop — a minor power surge while writing files to your drive can render your drive inoperable.

Let’s face it, whether your company uses Microsoft Windows, Macs, Linux, or Unix, the one thing they all have in common is that they are dependent on hard drives to store data.  Desktops, laptops, web servers are all susceptible to suddenly freezing up.

Whether you plan on saving money yourself and getting your IT department trained up or you would rather scale your resources externally and align your company with a competent data recovery business with a proven track record of reliability and success, it is imperative to be prepared BEFORE disaster strikes your business.

My worst hard drive nightmare

Back in 2005, my ad agency was working on producing a television infomercial with a tight deadline. You know, the kind of deadline you’re up until 2pm capturing video footage and not taking necessary precautions like making routine backups of your work – after all, high def video back then took up a lot of space. We had digitized over 30 hours of footage, assembled the video files and they were linked to our Avid video editing software. Back in those days, high def video wasn’t on small SDHC cards it fits so conveniently on now, we shot video to tapes then had to digitize the tapes and capture the video in real time.  So an hour of video footage took at least an hour to capture to a hard drive.

Two of our five 1TB external firewire drives failed to connect to our video editing computers. The worst part is that we were almost finished with the production job, we were at the “finishing touches” phase and we didn’t back up the project and footage somewhere else.  The client was scheduled to come into the studio for a review later that day and here we were, unable to even connect and access the files!

Instead of us putting our time and energy into finishing the production, we were scrambling and trying to figure out how to recover and access the project we had put in over 100 hours working on.

Hard Drive Rescue Under $100

Needless to say, we scoured the web and downloaded four different disk recovery programs online before we found one that worked. Some of the free versions allowed you to install their program and it would indeed scan your hard drive but you would be limited to restoring a certain amount of files. This limitation would be lifted once you purchased the license, which ranged anywhere from $50 to about $300 back then.

At the time, we were just desperate to access the files.  In this situation, disk recovery software saved us over 50 hours of redoing video production and editing work we would have had to do over.

Your business plan needs to include recoveries from catastrophes, natural and technological.

This is just one example of many scenarios hundreds of businesses across the world probably face every day.

ReclaiMe Data Recovery Software

One such data recovery solution is from ReclaiMe.  What really sets ReclaiMe apart is their free knowledgebase and training.

Though the ReclaiMe training courses are mostly for computer repair specialists or data recovery technicians, many companies rely on their internal IT departments to set up and take care of their own computers and hardware.  ReclaiMe’s Data Recovery Training website is a free comprehensive resource for a variety of systems, NAS, RAID, and partitions that provide valuable insights and techniques about how to restore critical data.

Being prepared and understanding more about the data recovery process is insurance for your company that will make sure when a hard drive fails, you will know the best courses of action to take to save time and money.

To read more about the review of ReclaiMe’s free online tutorials, click here.


In a jQuery form post, here is how you add more data to the serialized form data.  This is useful if you find yourself needing to pass some extra data along with the AJAX post.  This is a barebones example of a blind AJAX post to a form handler script called “form_handler.php”.

I find jQuery’s “serialize” and “serializeArray” functions are very efficient when collecting form data, you can’t get much easier than that.  The beauty of using a framework, whether it’s a Javascript framework, or PHP framework, these built-in libraries and functions save coding time.

var data = $('#myForm').serializeArray();

data.push({name: 'wordlist', value: wordlist});

$.post("form_handler.php", data);

I hope this saves someone time!  This solution works well in many different instances you have to post a form through Javascript.

– Aaron  Belchamber


In MySQL, if you have two tables with a shared index and you would like to show the results of one table where the index is not within another table, you can use “NOT IN”.

SELECT * FROM table2 WHERE some_field not in 
    (SELECT some_field FROM table1)

Try Googling “MySQL NOT IN” and you get everything but this command, it’s almost as if they need to have an alias for this simple command since these two words are in EVERYTHING and on so many web pages. Perhaps “NOTCONTAINEDIN” would be better, all in one word? Just a suggestion.

In the sub-select, the query inside parenthesis, you can take this a step further and apply conditions to the filter so you can exclude results in “table2” more narrowly than just being in “table1”, perhaps if “table1” had a status of “EXPIRED” in a field, then you could add that criteria to be more selective.