public static function QQ($params, $dbinfo = null) { if (!$dbinfo) { $dbinfo = \SYSTEM\system::getSystemDBInfo(); } $con = new \SYSTEM\DB\Connection($dbinfo); try { if ($dbinfo instanceof \SYSTEM\DB\DBInfoPG) { if (!\is_callable(static::get_class() . '::pgsql')) { throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no pgsql implementation present.'); } return $con->prepare(static::get_class(), static::pgsql(), $params); } else { if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS) { if (!\is_callable(static::get_class() . '::mysql')) { throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no mysql implementation present.'); } return $con->prepare(static::get_class(), static::mysql(), $params); } else { if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP && is_callable(static::amqp())) { if (!\is_callable(static::get_class() . '::amqp')) { throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no amqp implementation present.'); } return $con->prepare(static::get_class(), static::amqp(), $params); } else { if ($dbinfo instanceof \SYSTEM\DB\DBInfoSQLite) { if (!\is_callable(static::get_class() . '::sqlite')) { throw new \SYSTEM\LOG\ERROR(static::get_class() . ' failed: no sqlite implementation present.'); } return $con->prepare(static::get_class(), static::sqlite(), $params); } } } } } catch (\Exception $e) { throw new \Exception(static::get_class() . ' failed causing: ' . $e->getMessage(), $e->getCode(), $e); } throw new \Exception('Could not understand Database Settings. Check ur Database Settings'); }
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_stats_name_basic_querytime($filter, $db) { $result = array(); if (!$db) { $result = \SYSTEM\SQL\SYS_SAIMOD_LOG_BASIC_QUERYTIME::QA(array($filter)); } else { $con = new \SYSTEM\DB\Connection(new \SYSTEM\DB\DBInfoSQLite(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH) . $db)); $res = $con->prepare('basic_querytime', 'SELECT datetime(strftime("%s",' . \SYSTEM\SQL\system_log::FIELD_TIME . ') - strftime("%s",' . \SYSTEM\SQL\system_log::FIELD_TIME . ')%:filter,"unixepoch", "localtime") as day,' . 'count(*) as count,' . 'avg(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_avg,' . 'max(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_max,' . 'min(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_min' . ' FROM ' . \SYSTEM\SQL\system_log::NAME_MYS . ' GROUP BY day' . ' ORDER BY day DESC' . ' LIMIT 30;', array(':filter' => $filter)); while ($row = $res->next()) { $result[] = $row; } } return \SYSTEM\LOG\JsonResult::toString($result); }