PHP and Javascript database wrapper