That's exactly what I've been doing.
Plus, I autodetect in the connect code which machine/directory I'm in and connect to the appropriate databases for test or production.
You can also load balance in the connect section and / or detect failed backends and switch abstracted from the application.
I agree that you should keep the functions VERY generic, like connect_db, not connect_biz_rules_db and a dozen other connects.
$read_connect_id=connect_db($db_name,$server(s),$name,$pwd);
$result=query($read_connect_id,$query);
print build_table($result);
close_db($read_connect_id);
Or:
$write_connect_id=connect_db($dbname2,$server,$name,$pwd);
save_form_data($write_connect_id) or die("Couldn't save data to databas");
That's much easier to adjust and reuse.