summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
authorUrban Müller2014-11-05 17:08:14 +0100
committerUrban Müller2014-11-05 17:08:14 +0100
commit36ef5ac2f948ad9fba76ced08dde803ebe984ffe (patch)
tree3c3d80e7a6f2cf15539117d58fb23c902c994237 /it_dbi.class
parentdbf5fdd45b2f81afee895fe047153fc43640850c (diff)
downloaditools-36ef5ac2f948ad9fba76ced08dde803ebe984ffe.tar.gz
itools-36ef5ac2f948ad9fba76ced08dde803ebe984ffe.tar.bz2
itools-36ef5ac2f948ad9fba76ced08dde803ebe984ffe.zip
allow external use of _state_purgeshared (instant created tables used in testing)
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class7
1 files changed, 4 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 7425275..1b749eb 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -42,6 +42,7 @@ class it_dbi
var $_fields; # Array of name => array(Field,Type,Null,Key,Default,Extra,Length) of fields (public readonly)
var $_convertfunc; # Array of name => convert function (currently intval and floatval) for this field's values
var $_link; # DB link identifier (private)
+ var $_dbid; # string identifying db connection. used for _state_purgeshared from outside
/**
@@ -143,7 +144,7 @@ function createclass($p)
# Make sure singleton exists
$dbi = $GLOBALS['it_dbi'] ? $GLOBALS['it_dbi'] : new it_dbi(array('table' => null) + $p);
$p += $dbi->_p; # FIXME: (has to be checked for side effects!)
- $dbid = "{$p['user']}@{$p['server']}:{$p['db']}";
+ $dbid = $dbi->_dbid = "{$p['user']}@{$p['server']}:{$p['db']}";
if (!isset($dbi->_tables[$dbid]))
{
@@ -833,10 +834,10 @@ function _state_put($dbid, $state, $shared = true)
it_cache::put("dbi:$dbid", array('link' => null) + (array)$state); # link is not transferable
}
-function _state_purgeshared($dbid)
+function _state_purgeshared($dbid = null)
{
#var_dump("purgeshared", $dbid);
- it_cache::put("dbi:$dbid", array()); # Nuke shared cache
+ it_cache::put("dbi:" . ($dbid ? $dbid : $GLOBALS['it_dbi']->_dbid), array()); # Nuke shared cache
}
#