Move DB connection logic to DB.php where its  most likely going to be used
Fixed "can't use function return value in write content"