fixed possible unsafe SQL statement

Fix for: http://trac.i-mscp.net/ticket/836

The check if there already is an entry for a day now returns the ID so we know exactly which record to update.