WC_Data_Store_WP::update_lookup_table()
Update a lookup table for an object.
Method of the class: WC_Data_Store_WP{}
No Hooks.
Return
NULL
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->update_lookup_table( $id, $table );
- $id(int) (required)
- ID of object to update.
- $table(string) (required)
- Lookup table name.
Changelog
Since 3.6.0 | Introduced. |
WC_Data_Store_WP::update_lookup_table() WC Data Store WP::update lookup table code WC 9.4.2
protected function update_lookup_table( $id, $table ) { global $wpdb; $id = absint( $id ); $table = sanitize_key( $table ); if ( empty( $id ) || empty( $table ) ) { return false; } $existing_data = wp_cache_get( 'lookup_table', 'object_' . $id ); $update_data = $this->get_data_for_lookup_table( $id, $table ); if ( ! empty( $update_data ) && $update_data !== $existing_data ) { $wpdb->replace( $wpdb->$table, $update_data ); wp_cache_set( 'lookup_table', $update_data, 'object_' . $id ); } }