Place in code to tap/change id/pass/dbname

Hi, I am running multiple databases of piwik, and wish to use only one set of php code. So I need to modify the php code and dynamically change id/pass/dbname based on parameter settings in the querystring (and then cookie or session that parameter for subsequent calls).

I have managed to do this so far by tapping whenever there is a call to “new pdo” where just before that call, I insert my code. But I am looking for a place to tap just after the config file is read. Figuring out the point config is read has been difficult for me, as it is enveloped in multiple layers of code. Can you please help my identify such a tap location in the code.

Thanks in advance,

steve

Note on the above…

I am giving one db to each domain. I figured this is the way to go - as I have many. But piwik supports multiple domains per db, but then I figure all the data is crunched together, seriously reducing performance. Am I right?