My programming tips after 10 years of programming

Updated: 28th April 2022
Tags: php mysql


  1. Always backup your database at least once a month.
  2. Have autoincrement id for all entity tables.
  3. Before big destructive action on table, backup that table.
  4. Always log rare destructive (like delete 1 row) actions. Create table deleted stuff and make json dump of that row. Simply insert and forget.


  1. Always use prepared statements binding. SQL injection is not a joke (only when you need to run where in with thousands of values, and you are 100% sure data is secure, for example array of int id you can run it).
  2. Try to make a lot of helper functions. But don't make mess out of it. Group them by meaning. If there is specific type it is about, make class for that type and place there helper functions.
  3. Be carefull. PHP has a lot of awkardness. For example, intval on string that starts with number will return you that int number.
  4. Have max execution time 5 seconds for public PHP scripts or/and set PHP curl timeout for those pages.