CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing the civicrm database dynamically
Pages: [1]

Author Topic: Changing the civicrm database dynamically  (Read 614 times)

dragontree

  • Guest
Changing the civicrm database dynamically
March 09, 2011, 10:19:41 pm
I'm trying to syncronize certain contacts between different databases.
Is it possible to change the active database? It should look something like this:
Code: [Select]
civicrm_contact_get($params)
change the database
civicrm_contact_get($params)
the two queries get the contacts from different databases.


dragontree

  • Guest
Re: Changing the civicrm database dynamically
March 11, 2011, 12:02:02 am
I found a way but I'm not sure its the best one.
First of all I know that hacking core files is not good but I didnt see anohter way to do this.
I hacked the core/dao.php and db/dataobject.php files. I added some extra parameters to different functions and changed the _connect() function in the dataobject a bit so that i can choose which database to connect to.

So now CRM_Core_DAO::executeQuery() function accepts a database name as the last parameter. After that query api functions use the new database too.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing the civicrm database dynamically

This forum was archived on 2017-11-26.