From d77fead38b86a5310da5c793605b42f1dc8e389b Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 20 Sep 2007 13:48:40 +0000 Subject: Use singleton defaults only for same db/server, fix passwords with dollar signs --- it_dbi.class | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'it_dbi.class') diff --git a/it_dbi.class b/it_dbi.class index d7f7e20..d91e1f7 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -51,9 +51,13 @@ function it_dbi($config = array(), $query = null) if (!is_array($config)) $config = array('table' => $config); - # If global singleton $it_dbi exists, use its defaults (db, user, pw, host) + # If global singleton $it_dbi exists, use its defaults (db, user, pw, server) $defaults = $GLOBALS['it_dbi']->_defaults ? eval("return array({$GLOBALS['it_dbi']->_defaults});") : array(); + # If the global singleton defaults are for another db, server or server_update then do not use them. + if (($config['db'] != $defaults['db']) || ($config['server'] != $defaults['server']) || ($config['server_update'] != $defaults['server_update'])) + $defaults = array(); + # Create current settings foreach ($config + $defaults + (array)$GLOBALS['it_dbi_defaultconfig'] + $this->_defaultconfig as $key => $value) { @@ -73,7 +77,7 @@ function it_dbi($config = array(), $query = null) $this->_defaults = ""; foreach($config as $key => $value) if ($key != 'createclasses') - $this->_defaults .= "'$key' => '".strtr($value, array('\'' => '\\\'', '$' => '\\$'))."', "; + $this->_defaults .= "'$key' => '".strtr($value, array('\'' => '\\\''))."', "; if ($this->_createclasses) { @@ -373,7 +377,7 @@ function query($query) if ($this->_link = @mysql_connect($this->_server_update, $this->_user, $this->_pw, true)) { if (!mysql_select_db($this->_db, $this->_link)) - $this->_fatal("Error selecting update database '$this->_db' on host '$this->_server_update'."); + $this->_fatal("Error selecting update database '$this->_db' on server '$this->_server_update'."); $this->_server = $this->_server_update; unset($this->_server_update); -- cgit v1.2.3