Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Automator_DB::drop_view( string $view_name = '' )

Drops the selected view.


Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Parameters Parameters

$view_name

(Optional) The name of the view.

Default value: ''


Top ↑

Return Return

(boolean) True if view was dropped. Otherwise, false.


Source Source

File: src/core/class-automator-db.php

	public static function drop_view( $view_name = '' ) {
		global $wpdb;
		$dropped = false;
		$views = self::get_views();
		// Only allow dropping of view owned by Automator.
		if ( in_array( $view_name, array_keys( $views ), true ) ) {
			$dropped = $wpdb->query(
			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
				str_replace(
					"'",
					'',
					$wpdb->prepare(
						'DROP VIEW IF EXISTS `%s`',
						esc_sql( filter_var( $views[ $view_name ], FILTER_SANITIZE_FULL_SPECIAL_CHARS ) )
					)
				)
			);
		}
		return $dropped;
	}