Started copying the connect function from the standard MySQL wrapper. Need to wrap my head round how it all works before continuing I think...