Refactor save() in database.php: check input data validity and return true or false based on operation successfulness