ok
Your code connects to the db thus ending the connection with the db from wb
Solution, reconnect to the db from within wb right before you leave your code thus restoring all db connections wb need
At the end of your code put:
$database = new database();
to restore the db
Think this will do
Have fun,
John