get_col( $wpdb->prepare( // %i → identifier (table name), %s → string (cutoff datetime) 'SELECT log_id FROM %i WHERE created_date < %s', $wpdb->prefix . 'atk_ai_logs', $cutoff ) ); // 4) Delete each old record safely if ( ! empty( $old_ids ) ) { foreach ( $old_ids as $log_id ) { $wpdb->delete( $wpdb->prefix . 'atk_ai_logs', [ 'log_id' => absint( $log_id ) ], [ '%d' ] ); } } } } // Initialize the cleanup class new ATKAI_AI_Logs_Cleanup(); }