Fixed getCount methods

We fixed a bug concerning the getCount methods. The where and join informations wasnt added to the query propperly.

I added a pivot variable to switch to a external QueryBuilder if one was passed to the join / where methods.