schema_name = sanitize_text_field( wp_unslash( $_REQUEST['wpdaschema_name'] ) ); // input var okay. $this->table_name = str_replace( '`', '', sanitize_text_field( wp_unslash( $_REQUEST['table_name'] ) ) ); // input var okay. $this->rownum = sanitize_text_field( wp_unslash( $_REQUEST['rownum'] ) ); // input var okay. $wpda_data_dictionary = new WPDA_Dictionary_Exist($this->schema_name, $this->table_name); if ( !$wpda_data_dictionary->table_exists() ) { echo '
' . __( 'ERROR: Invalid table name or not authorized', 'wp-data-access' ) . '
'; return; } $wp_nonce = ( isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '?' ); // input var okay. if ( !wp_verify_nonce( $wp_nonce, "wpda-actions-{$this->table_name}" ) ) { echo '
' . __( 'ERROR: Not authorized', 'wp-data-access' ) . '
'; return; } $this->dbo_type = ( isset( $_REQUEST['dbo_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['dbo_type'] ) ) : null ); // input var okay. $this->is_wp_table = WPDA::is_wp_table( $this->table_name ); $this->engine = WPDA_Dictionary_Lists::get_engine( $this->schema_name, $this->table_name ); $wpdadb = WPDADB::get_db_connection( $this->schema_name ); if ( null === $wpdadb ) { wp_die( sprintf( __( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $this->schema_name ) ) ); } $query = "show full columns from `{$wpdadb->dbname}`.`{$this->table_name}`"; $this->table_structure = $wpdadb->get_results( $query, 'ARRAY_A' ); if ( stripos( $this->dbo_type, 'table' ) !== false ) { $this->dbo_type = 'Table'; $query = "show create table `{$wpdadb->dbname}`.`{$this->table_name}`"; $create_table = $wpdadb->get_results( $query, 'ARRAY_A' ); if ( isset( $create_table[0]['Create Table'] ) ) { $this->create_table_stmt_orig = $create_table[0]['Create Table']; $this->create_table_stmt = preg_replace( '/\\(/', '
(', $this->create_table_stmt_orig, 1 ); $this->create_table_stmt = preg_replace( '/\\,\\s\\s\\s/', '
, ', $this->create_table_stmt ); $pos = strrpos( $this->create_table_stmt, ')' ); if ( false !== $pos ) { $this->create_table_stmt = substr( $this->create_table_stmt, 0, $pos - 1 ) . '
)' . substr( $this->create_table_stmt, $pos + 1 ); } $query = "show indexes from `{$wpdadb->dbname}`.`{$this->table_name}`"; $this->indexes = $wpdadb->get_results( $query, 'ARRAY_A' ); $query = $wpdadb->prepare( ' select constraint_name AS constraint_name, column_name AS column_name, referenced_table_name AS referenced_table_name, referenced_column_name AS referenced_column_name from information_schema.key_column_usage where table_schema = %s and table_name = %s and referenced_table_name is not null order by ordinal_position ', array($wpdadb->dbname, $this->table_name) ); $this->foreign_keys = $wpdadb->get_results( $query, 'ARRAY_A' ); } else { $this->create_table_stmt = __( 'Error reading create table statement', 'wp-data-access' ); } } elseif ( strtoupper( $this->dbo_type ) === 'VIEW' ) { $this->dbo_type = 'View'; $query = "show create view `{$wpdadb->dbname}`.`{$this->table_name}`"; $create_table = $wpdadb->get_results( $query, 'ARRAY_A' ); if ( isset( $create_table[0]['Create View'] ) ) { $this->create_table_stmt_orig = $create_table[0]['Create View']; $this->create_table_stmt = str_replace( 'AS select', 'AS
select', $this->create_table_stmt_orig ); $this->create_table_stmt = str_replace( 'from', '
from', $this->create_table_stmt ); } } $this->wpda_list_columns = WPDA_List_Columns_Cache::get_list_columns( $this->schema_name, $this->table_name ); ?>
tab_actions(); ?>
dbo_type ) { ?> dbo_type ) { ?> dbo_type ) { ?> dbo_type || 'View' === $this->dbo_type ) { ?>
table_name, $this->schema_name ); if ( isset( $settings_db[0]['wpda_table_settings'] ) ) { $settings_db_custom = json_decode( $settings_db[0]['wpda_table_settings'] ); $sql_dml = 'UPDATE'; } else { $settings_db_custom = (object) null; $sql_dml = 'INSERT'; } if ( has_filter( 'wpda_add_column_settings' ) ) { // Use filter $column_settings_add_column = apply_filters( 'wpda_add_column_settings', null ); } if ( isset( $column_settings_add_column ) && is_array( $column_settings_add_column ) ) { $array_valid = true; foreach ( $column_settings_add_column as $add_column ) { if ( !isset( $add_column['label'] ) || !isset( $add_column['hint'] ) || !isset( $add_column['name_prefix'] ) || !isset( $add_column['type'] ) || !isset( $add_column['default'] ) || !isset( $add_column['disable'] ) ) { $array_valid = false; break; } } if ( !$array_valid ) { $column_settings_add_column = array(); } } else { $column_settings_add_column = array(); } $row_count_is_configurable = 'innodb' === strtolower( $this->engine ) || 'federated' === strtolower( $this->engine ) || 'connect' === strtolower( $this->engine ) || $this->engine === null; ?>
    schema_name, $this->table_name, $this->table_structure ); ?>
    • table_settings->row_count_estimate_value ) ) { $row_count_estimate_value = $settings_db_custom->table_settings->row_count_estimate_value; } ?>


      Performs real row count if estimate <= . Uses estimated row count if estimate > .

      table_settings->query_buffer_size ) ) { echo 'value="' . esc_attr( $settings_db_custom->table_settings->query_buffer_size ) . '"'; } ?> />



    • wpda_list_columns->get_table_column_headers(); $media_pool = WPDA_Media_Model::get_pool(); $media_cols = array(); if ( isset( $media_pool[$this->schema_name][$this->table_name] ) ) { $media_cols = $media_pool[$this->schema_name][$this->table_name]; } foreach ( $this->table_structure as $column ) { $label_list_table = $this->wpda_list_columns->get_column_label( $column['Field'] ); $label_data_entry = ( isset( $columns[$column['Field']] ) ? $columns[$column['Field']] : '' ); $option = ( isset( $media_cols[$column['Field']] ) ? $media_cols[$column['Field']] : '' ); ?>
      '; } ?> wpda_list_columns->get_table_primary_key(); if ( in_array( $column['Field'], $primary_key ) ) { //phpcs:ignore - 8.1 proof echo 'disabled="disabled" title="Not available for key columns"'; } } if ( 'checkbox' === $add_column['type'] ) { $column_name = $add_column['name_prefix'] . esc_attr( $column['Field'] ); if ( isset( $settings_db_custom->custom_settings->{$column_name} ) ) { echo ( $settings_db_custom->custom_settings->{$column_name} ? 'checked' : '' ); } else { echo esc_attr( $add_column['default'] ); } } ?> >'; } ?>

  • settings_tab_dynamic_hyperlinks( $settings_db_custom ); $this->settings_tab_dashboard_menus(); $this->settings_tab_rest_api(); do_action( 'wpda_append_table_settings' ); ?>
  • false, 'select' => array( 'methods' => [], 'authorization' => 'authorized', 'authorized_roles' => array(), 'authorized_users' => array(), ), 'insert' => array( 'methods' => [], 'authorization' => 'authorized', 'authorized_roles' => array(), 'authorized_users' => array(), ), 'update' => array( 'methods' => [], 'authorization' => 'authorized', 'authorized_roles' => array(), 'authorized_users' => array(), ), 'delete' => array( 'methods' => [], 'authorization' => 'authorized', 'authorized_roles' => array(), 'authorized_users' => array(), ), ); $rest_api_settings_saved = get_option( WPDA_API::WPDA_REST_API_TABLE_ACCESS ); if ( isset( $rest_api_settings_saved[$this->schema_name][$this->table_name] ) ) { $actions = array( 'select', 'insert', 'update', 'delete' ); foreach ( $actions as $action ) { if ( isset( $rest_api_settings_saved[$this->schema_name][$this->table_name][$action] ) ) { $rest_api_settings = $this->get_table_settings( $rest_api_settings, $rest_api_settings_saved[$this->schema_name][$this->table_name], $action ); } } } ?>
  • >

    Supported HTTP methods

    URLs and parameters

    (select multiple rows) '; $select_url = esc_url( get_rest_url( null, "wpda/table/get" ) ); echo $select_url; ?> (select single row)

    Authorization

    Select roles to grant access
    Select users to grant access
    >
    table_structure as $column ) { ?>
    create_table_stmt_orig, 'ENGINE=InnoDB' ) ) { ?> foreign_keys ) ) { //phpcs:ignore - 8.1 proof echo ''; } $constraint_name = ''; foreach ( $this->foreign_keys as $foreign_key ) { $show_item = $constraint_name !== $foreign_key['constraint_name']; ?>
    ' . __( 'No foreign keys defined for this table', 'wp-data-access' ) . '
    indexes ) ) { //phpcs:ignore - 8.1 proof echo ''; } $current_index_name = ''; foreach ( $this->indexes as $index ) { if ( $current_index_name !== $index['Key_name'] ) { $current_index_name = esc_attr( $index['Key_name'] ); $new_index = true; } else { $new_index = false; } ?>
    #
    ' . __( 'No indexes defined for this table', 'wp-data-access' ) . '
    create_table_stmt, array( 'br' => array(), ) ); ?>
    tab_export(); if ( $this->is_wp_table === false && ('Table' === $this->dbo_type || 'View' === $this->dbo_type) && !$is_pds ) { $this->tab_rename(); } if ( 'Table' === $this->dbo_type ) { $this->tab_copy(); } if ( 'Table' === $this->dbo_type && $this->is_wp_table === false && !$is_pds ) { $this->tab_truncate(); } if ( $this->is_wp_table === false && ('Table' === $this->dbo_type || 'View' === $this->dbo_type) ) { $this->tab_drop(); } if ( 'Table' === $this->dbo_type && !$is_pds ) { $this->tab_optimize(); } if ( 'Table' === $this->dbo_type ) { $this->tab_alter(); } if ( $is_pds ) { // Premium data service connection $this->pds(); } ?>
    table_name ); $wp_nonce = wp_create_nonce( $wp_nonce_action ); $sql_option_prefix = ''; $export_variable_prefix_option = false; if ( 'Table' === $this->dbo_type ) { $export_variable_prefix_option = 'on' === WPDA::get_option( WPDA::OPTION_BE_EXPORT_VARIABLE_PREFIX ); } ?> `table_name ); ?>` : table_name}"; $wp_nonce_rename = wp_create_nonce( $wp_nonce_action_rename ); $rename_table_form_id = 'rename_table_form_' . esc_attr( $this->table_name ); $rename_table_form = '" . "" . "" . "" . "" . ''; ?> dbo_type ) ); ?> `table_name ); ?>` to: table_name}"; $wp_nonce_copy = wp_create_nonce( $wp_nonce_action_copy ); $copy_table_form_id = 'copy_table_form_' . esc_attr( $this->table_name ); $copy_table_form = '" . "" . "" . "" . "" . "" . "" . "" . ''; ?> dbo_type ) ); ?> `table_name ); ?> ` : table_name}"; $wp_nonce_truncate = wp_create_nonce( $wp_nonce_action_truncate ); $truncate_table_form_id = 'truncate_table_form_' . esc_attr( $this->table_name ); $truncate_table_form = '" . "" . "" . "" . ''; ?> dbo_type ) ); ?> `table_name ); ?>` .
    table_name}"; $wp_nonce_drop = wp_create_nonce( $wp_nonce_action_drop ); if ( 'View' === $this->dbo_type ) { $msg_drop = __( 'Drop view?', 'wp-data-access' ); } else { $msg_drop = __( 'Drop table?', 'wp-data-access' ); } $drop_table_form_id = 'drop_table_form_' . esc_attr( $this->table_name ); $drop_table_form = '" . "" . "" . "" . ''; ?> dbo_type ) ); ?> `table_name ); ?>`
    schema_name ); if ( null === $wpdadb ) { wp_die( sprintf( __( 'ERROR - Remote database %s not available', 'wp-data-access' ), esc_attr( $this->schema_name ) ) ); } $table_structure = $wpdadb->get_row( $wpdadb->prepare( 'show table status like %s', $this->table_name ) ); $query_innodb_file_per_table = $wpdadb->get_row( "show session variables like 'innodb_file_per_table'" ); if ( !empty( $query_innodb_file_per_table ) ) { $innodb_file_per_table = 'ON' === $query_innodb_file_per_table->Value; } else { $innodb_file_per_table = true; } if ( 'InnoDB' === $table_structure->Engine && !$innodb_file_per_table ) { return; } $consider_optimize = $table_structure->Data_free > 0 && $table_structure->Data_length > 0 && $table_structure->Data_free / $table_structure->Data_length > 0.2; $wp_nonce_action_optimize = "wpda-optimize-{$this->table_name}"; $wp_nonce_optimize = wp_create_nonce( $wp_nonce_action_optimize ); $optimize_table_form_id = 'optimize_table_form_' . esc_attr( $this->table_name ); $optimize_table_form = '" . "" . "" . "" . ''; $msg_optimize = __( 'Optimize table?', 'wp-data-access' ); ?> dbo_type ) ); ?> `table_name ); ?>`.
    table_name}"; $wp_nonce_alter = wp_create_nonce( $wp_nonce_action_alter ); $alter_table_form_id = 'alter_table_form_' . esc_attr( $this->table_name ); $alter_table_form = '" . "" . "" . "" . "" . "" . "" . "" . "" . "" . ''; ?> dbo_type ) ); ?> `table_name ); ?>`