Reset num_queries to 0 if more than 500 queries so as not to connect with every new query on long running scripts.
Merge remote branch 'origin/master'
Declare $rows_affected (thx https://github.com/nolan-interactive)
Merge remote branch 'origin/master'