summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2007-09-20 13:48:40 +0000
committerChristian Schneider2007-09-20 13:48:40 +0000
commitd77fead38b86a5310da5c793605b42f1dc8e389b (patch)
tree9ce3988cc22d1565d0a624458781b5aa6bfb09c6
parentd0d66a94138d61dcd700380f584a85a483c184fe (diff)
downloaditools-d77fead38b86a5310da5c793605b42f1dc8e389b.tar.gz
itools-d77fead38b86a5310da5c793605b42f1dc8e389b.tar.bz2
itools-d77fead38b86a5310da5c793605b42f1dc8e389b.zip
Use singleton defaults only for same db/server, fix passwords with dollar signs
-rw-r--r--it_dbi.class10
1 files changed, 7 insertions, 3 deletions
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);