function now accepts a handle to a PDO database