/** * 返回文件名數組列表 * @return array */ public function getDirFileName(){ $dir = ROOT_PATH.'runtime/log'; $data = scandir($dir); return $data; } /** * @param $filename 文件路徑 * @param $table 表名 * @param string $action * @return array */ public function readLog($filename,$table,$action='INSERT'){ $handle = fopen ($filename, "r"); while (!feof ($handle)) { $buffer = fgets($handle, 4096); $data = trim($buffer); if ($data !='---------------------------------------------------------------'){ if (strpos($data,$table)!=false ){ if (strpos($data,$action)!=false){ $str = str_replace('[ sql ] [ SQL ]','',$data); $str = substr($str,0,strrpos($str,"[")); $arr[] = $str; } } } } fclose ($handle); return $arr; }
thinkphp5.0日誌讀取
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.