Forums / Install & configuration / Two database connections

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Two database connections

Author Message

Sjoerd van Steijn

Tuesday 21 December 2004 12:41:13 am

I want to use a dedicated database for an extension so i can use the same extension in different ez sites. When i try to connect to the extension database for inserting data, the site data will not be shown. What do i do wrong or is it impossible to have 2 database connections at once.

When i use getDB the ez content won't be shown.

* * * script * * * * * * * * *

function getDB($dbname = "") {

global $arrdbaccess;
if ($dbname == "") {
$dbname = $arrdbaccess["dbname"];
}

if (mysql_select_db ( $dbname )) {
return true;
} else {
return false;
}
}

function run_thisquery($query, $strid = "") {
global $arrdbaccess, $objconn;
$dbname = $arrdbaccess["dbname"];

#voer een insert of update query uit. retourneer bij een insert het autoincrement id
openConnection($objconn);
mysql_select_db ( $dbname );
mysql_query($query);

if (($strid == "") or ($strid == "0")) {
$strid = mysql_insert_id();
}
mysql_query("COMMIT");
closeConnection($objconn);
return $strid;
}

Shafiq Far

Wednesday 02 February 2005 7:44:04 am

Hi-

I'm having the same problem - <i>except using PostgreSQL.</i>

If anyone around knows how to get around this please let me know.

Thanks,

Sjoerd van Steijn

Tuesday 15 February 2005 6:03:47 am

I think the reason why i can't make two database connections is to protect other websites. I have found a solution to work around this problem. I removed the getDB function in the module and used the global variable arrdbaccess["dbname"] in the queries (in my module classes) to contact the database correctly. for example

function functionname($var1,$var2) {
global $arrdbaccess;

$sql="SELECT field1 FROM ".$arrdbaccess['dbname'].".table WHERE field2='".$var1."' and field3='".$var2."' ";

$result = run_rentequery($sql);
return $result;
}