table}$whereClause"; $totalCount = $this->db->fetchColumn($countQuery, $params); $offset = ($page - 1) * $limit; // Get data with pagination $query = " SELECT a.*, u.username FROM {$this->table} a LEFT JOIN users u ON a.user_id = u.id $whereClause ORDER BY a.created_at DESC LIMIT ? OFFSET ? "; $queryParams = array_merge($params, [$limit, $offset]); $logs = $this->db->fetchAll($query, $queryParams); return [ 'logs' => $logs, 'pagination' => [ 'total' => $totalCount, 'page' => $page, 'limit' => $limit, 'pages' => ceil($totalCount / $limit) ] ]; } }