/** * 收集当前请求执行过的SQL,写入8.188上的swoole * @return [type] [description] */ public static function getSql() { if (DI::getDefault()->has('profiler')) { $sqlArr = array(); $url = $_SERVER['HTTP_HOST'] . '/?' . $_SERVER['QUERY_STRING']; $sqlStaticsUrl = "http://192.168.8.188:9671/"; //统计SQL的URL $profiles = DI::getDefault()->get('profiler')->getProfiles(); if (empty($profiles)) { return ''; } foreach ($profiles as $profile) { $sqlArr[] = array('sql' => $profile->getSQLStatement(), 'time' => $profile->getTotalElapsedSeconds() * 1000, 'url' => $url); } $url = $sqlStaticsUrl . "?type=file&cmd=sqlStatics¶m=" . urlencode(json_encode($sqlArr)); \Xz\Func\ReqHelp::get($url, 2); return $sqlArr; } }