insert( Argus_DB::table( 'scan_history' ), array( 'scan_type' => $type, 'started_at' => gmdate( 'Y-m-d H:i:s', $started_at ), 'finished_at' => current_time( 'mysql', true ), 'files_scanned' => (int) $files_scanned, 'findings_count' => $findings_count, 'result' => $findings_count > 0 ? 'issues' : 'clean', ) ); } public static function paginated( $page = 1, $per_page = self::PER_PAGE ) { global $wpdb; $table = Argus_DB::table( 'scan_history' ); $page = max( 1, (int) $page ); $offset = ( $page - 1 ) * $per_page; $total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" ); // phpcs:ignore $rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table} ORDER BY started_at DESC LIMIT %d OFFSET %d", $per_page, $offset ) // phpcs:ignore ); return array( 'rows' => $rows, 'total' => $total, 'total_pages' => max( 1, (int) ceil( $total / $per_page ) ), 'page' => $page, ); } }