prefix . $this->table; if( $table !== NULL ) { $table_name = $table; } $safe_table_name = '`' . str_replace( '`', '``', $table_name ) . '`'; $safe_wher_name = '`' . sanitize_key( $wher_name ) . '`'; $cache_group = 'mxasts'; $cache_key = 'row_' . md5( $table_name . '|' . $wher_name . '|' . $wher_value ); $found = false; $get_row = wp_cache_get( $cache_key, $cache_group, false, $found ); if ( false === $found ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $get_row = $wpdb->get_row( $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT * FROM {$safe_table_name} WHERE {$safe_wher_name} = %s", $wher_value ) ); wp_cache_set( $cache_key, $get_row, $cache_group ); } return $get_row; } /** * get results from the database */ public function mxasts_get_results( $table = false, $wher_name = NULL, $wher_value = 1 ) { global $wpdb; $table_name = $wpdb->prefix . $this->table; if( $table !== false ) { $table_name = $table; } $safe_table_name = '`' . str_replace( '`', '``', $table_name ) . '`'; $cache_group = 'mxasts'; $cache_key = 'results_' . md5( $table_name . '|' . $wher_name . '|' . $wher_value ); $found = false; $results = wp_cache_get( $cache_key, $cache_group, false, $found ); if ( false === $found ) { if( $wher_name !== NULL ) { $safe_wher_name = '`' . sanitize_key( $wher_name ) . '`'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $results = $wpdb->get_results( $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT * FROM {$safe_table_name} WHERE {$safe_wher_name} = %s", $wher_value ) ); } else { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $results = $wpdb->get_results( "SELECT * FROM {$safe_table_name}" ); } wp_cache_set( $cache_key, $results, $cache_group ); } return $results; } }