Show last query

	static function actions_logs($type, $options=null){
		DB::enableQueryLog();

		$result = DB::table('member_action_log as a')
			->join('member as b', 'b.id', '=', 'a.editor')
			->leftJoin('member as c', 'c.id', '=', 'a.member')
			->join('options as d', 'd.id', '=', 'a.action_id')
			->select('a.*', 'b.username as editor_name', 'c.username as member_name', 'd.name as action_name')
			->where('b.type', '=', $type);

		if(val($options, 'keyword') != false){
			$keyword = val($options, 'keyword');
			$result = $result->where(function ($query) use ($keyword) {
                $query->orWhere('b.username', 'like', "%" . $keyword . "%")
                      ->orWhere('b.name', 'like', "%" . $keyword . "%");
            });
		}

		$result = $result->orderBy('a.created_time', 'desc')
			->get();

		$queries = DB::getQueryLog();
		logg(end($queries));

		return $result;
	}

Reference:

Replace ? with values

public static function getQueryString()
{
    $queryLog  = DB::getQueryLog();
    $lastQuery = end($queryLog);
    $stringSql = $lastQuery['query'];
 
    // 取代所有問號
    $stringSql = preg_replace("/\?/", "'?'", $stringSql);
 
    // query 重組
    foreach( $lastQuery['bindings'] as $arg ) {
        $stringSql = preg_replace("/\?/", $arg, $stringSql, 1);
    }
 
    return $stringSql;
}