diff options
Diffstat (limited to 'it_dbi.class')
-rw-r--r-- | it_dbi.class | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/it_dbi.class b/it_dbi.class index 6383910..e51b23e 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -151,8 +151,8 @@ static function createclass($p) $p = array('table' => $p); # Make sure singleton exists - $dbi = $GLOBALS[static::$_global_key] ?: new static::$_global_key(['table' => null] + $p); - $p += $dbi->_p; # FIXME: (has to be checked for side effects!) + $dbi = $GLOBALS[static::$_global_key] ? $GLOBALS[static::$_global_key] : new static::$_global_key(['table' => null] + $p); + $p += $dbi->_p; $dbid = $dbi->_dbid = "{$p['user']}@{$p['server']}:{$p['db']}"; if (!isset($dbi->_tables[$dbid])) @@ -488,26 +488,6 @@ function _fatal($text, $body = null) } /** - * Post-process data after reading a record. - * This is a stub-function that can be overloaded. - */ -function _read_post_process() -{ -} - - -/** - * Pre-process data before writing a record. - * This is a stub-function that can be overloaded. - * @param $tags Reference to update/create tags, can be modified as needed - * @param $command SQL command ('INSERT', 'REPLACE' or 'UPDATE') - */ -function _write_pre_process(&$tags, $command) # NOPHPLINT FIXME 2020-12 CS Remove legacy hooks now replace by pure and static versions -{ -} - - -/** * Hook to postprocess data after reading a record. * This is a stub-function that can be overloaded. * @param $data Data of record read from db @@ -592,7 +572,10 @@ function query($query, $p = array()) } if ($writing && $this->_p['throttle_writes']) + { + it::log('debug', 'dbi-throttle', 1000000 * (gettimeofday(true) - $start) * $this->_p['throttle_writes']); usleep(1000000 * (gettimeofday(true) - $start) * $this->_p['throttle_writes']); + } $msec = round(1000 * (gettimeofday(true) - $start)); $slow = $msec >= 2000; @@ -756,8 +739,6 @@ function iterate() if ($this->_p['unbuffered']) $this->_result->close(); } - - $this->_read_post_process(); } else $this->_nofetch = false; @@ -781,7 +762,6 @@ function insert($tags = array(), $command = "INSERT", $suffix = "") /* Pre-processing, $tags is passed by reference and may be modified here */ $tags = static::_write_preprocess($tags); - $this->_write_pre_process($tags, $command); if ($this->_p['randomid'] && !isset($tags[$this->_p['keyfield']])) $tags[$this->_p['keyfield']] = bin2hex(random_bytes(16)); @@ -840,7 +820,6 @@ function update($tags = array(), $where = null) /* Pre-processing, $tags is passed by reference and may be modified here */ $tags = static::_write_preprocess($tags); - $this->_write_pre_process($tags, 'UPDATE'); if ($set = $this->_set($tags, isset($where))) { |