Adding some changes from Mr-Dave (https://github.com/Mr-Dave/motion/commit/fe8c8016870d055f1f894bfd3806e9a8b736cc7c)
Changing some of the mysql changes for event ids