diff options
-rw-r--r-- | it_dbi.class | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/it_dbi.class b/it_dbi.class index ee6d268..ab132ff 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -38,6 +38,7 @@ class it_dbi 'classprefix' => "", 'getfieldinfo' => true, # do not read schema. only select() allowed 'localized_defaultlanguage' => "de", # Localize fields with this suffix, e.g. copy title_de to title on read + 'throttle_writes' => 0, # sleep for 'throttle_writes' multiplied by the execution time after every write 'unbuffered' => false, # use MYSQLI_USE_RESULT (WARNING this is not at all equivalent to normal it_dbi WARNING) ); @@ -489,7 +490,7 @@ function query($query, $p = array()) $p += $this->_p; $start = gettimeofday(true); - if (!it::match('^(EXPLAIN|SELECT|SHOW)', $query, array('utf8' => false))) + if (($writing = !it::match('^(EXPLAIN|SELECT|SHOW)', $query, array('utf8' => false)))) { if ($p['server_update']) { @@ -529,6 +530,8 @@ function query($query, $p = array()) it_dbi::_state_purgeshared($dbid); } + if ($writing && $this->_p['throttle_writes']) + usleep(1000000 * (gettimeofday(true) - $start) * $this->_p['throttle_writes']); $msec = round(1000 * (gettimeofday(true) - $start)); $slow = $msec >= 2000; |