title: MySQL custom primary key generator
body: <p>I have written an invoice module for our reservation system.</p>
  
  <p>So when I create a new invoice, I automatically generate a primary key through MySQL.</p>
  
  <p>However for the moment this is just a simple integer counting up.</p>
  
  <p>The problem is that we are obligated to have an invoice number in the form of "#year#id" where #year is e.g. 2013 and #id is an id that start every year back at 1.</p>
  
  <p>So e.g. 20131, 20132, 20133 and in 2014 it wil be 20141, 20142.</p>
  
  <p>How can I fix this with a custom primary key generator?</p>