Forums / Install & configuration / Two database connections

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;
}

eZ debug

Timing: Jan 19 2025 15:12:16
Script start
Timing: Jan 19 2025 15:12:16
Module start 'content'
Timing: Jan 19 2025 15:12:17
Module end 'content'
Timing: Jan 19 2025 15:12:17
Script end

Main resources:

Total runtime0.7395 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 590.1094180.8281
Module start 'content' 0.00480.6356 770.9375482.2813
Module end 'content' 0.64040.0990 1,253.2188333.5000
Script end 0.7394  1,586.7188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4782210.0002
Check MTime0.00140.1874210.0001
Mysql Total
Database connection0.00060.078310.0006
Mysqli_queries0.679091.81801940.0035
Looping result0.00140.18941920.0000
Template Total0.716296.920.3581
Template load0.00170.230720.0009
Template processing0.714596.625620.3573
Template load and register function0.00010.017710.0001
states
state_id_array0.00070.095310.0007
state_identifier_array0.00060.086320.0003
Override
Cache load0.00150.1975450.0000
Sytem overhead
Fetch class attribute can translate value0.00120.156530.0004
Fetch class attribute name0.00110.155230.0004
XML
Image XML parsing0.00080.106330.0003
class_abstraction
Instantiating content class attribute0.00000.001430.0000
General
dbfile0.00400.5415210.0002
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs