}
return true;
}
-
-
- function jsencode($v, $header = false)
- {
- if ($header) {
- header("Content-type: text/javascript");
- }
- if (function_exists("json_encode")) {
- $ret= json_encode($v);
- if ($ret !== false) {
- return $ret;
- }
- }
- require_once 'Services/JSON.php';
- $js = new Services_JSON();
- return $js->encodeUnsafe($v);
-
-
-
- }
}
+ /**
+ * while doing batch processes, the database sometimes get's locked up.
+ * if we are doing another batch process that can be avoided - we should just stop for a while..
+ */
-
-
+ function database_is_locked()
+ {
+ $cd = DB_DataObject::Factory('core_enum');
+ $cd->query("show processlist");
+ $locked = 0;
+ while ($cd->fetch()) {
+ if ($cd->State == 'Waiting for table metadata lock') {
+ $locked++;
+ }
+ if ($locked> 10) {
+ return true;
+ }
+ }
+ return false;
+ }