SugarCRM and multiple databases
When I’ve tried to develop my own module to integrate SugarCRM and RT2 I was surprised SugarCRM dosn’t suport using more than one database at one time! I’m a new in PHP. That’s why I spent a time to find why SugarCRM didn’t work at all! Probably, it is not good solution to connect to the database directly instead of using some webservice. But RT2 doesn’t provide any webservices (I’m going to create some webservice for RT2). The magical patch is here 🙂
--- /home/misha/tmp/PearDatabase.php 2005-08-17 17:40:36.000000000 +0300
+++ /var/www/sugarcrm/include/database/PearDatabase.php 2005-07-01 18:01:00.000000000 +0300
@@ -184,7 +184,7 @@
$this->checkConnection();
$this->query_time = microtime();
if($this->dbType == "mysql"){
- $result =& mysql_query($SQL);
+ $result =& mysql_query($sql, $this->database);
$this->lastmysqlrow = -1;
}
else if ($this->dbType == "oci8") {
The fact that PHP would use last opened mysql connection, unless you explicitly specify one is pretty stupid IMO.
“Pretty stupid” specify connection handler directly or use last one?
Just as I said – the fact that it uses last one. I agree, that it makes life easier in some cases, but if you have more than one opened connection at a time, it could be too easy to make a mistake.
How about case if you need to copy some data from one database to another, for example?