Move MySQL code into db.php

Signed-off-by: Thiago Farina <tfarina@chromium.org>