WC_Data_Store_WP::get_db_info
Table structure is slightly different between meta types, this function will return what we need to know.
Метод класса: WC_Data_Store_WP{}
Хуков нет.
Возвращает
Массив. Array elements: table, object_id_field, meta_id_field
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_db_info();
Список изменений
| С версии 3.0.0 | Введена. |
Код WC_Data_Store_WP::get_db_info() WC Data Store WP::get db info WC 10.7.0
protected function get_db_info() {
global $wpdb;
$meta_id_field = 'meta_id'; // for some reason users calls this umeta_id so we need to track this as well.
$table = $wpdb->prefix;
// If we are dealing with a type of metadata that is not a core type, the table should be prefixed.
if ( ! in_array( $this->meta_type, array( 'post', 'user', 'comment', 'term' ), true ) ) {
$table .= 'woocommerce_';
}
$table .= $this->meta_type . 'meta';
$object_id_field = $this->meta_type . '_id';
// Figure out our field names.
if ( 'user' === $this->meta_type ) {
$meta_id_field = 'umeta_id';
$table = $wpdb->usermeta;
}
if ( ! empty( $this->object_id_field_for_meta ) ) {
$object_id_field = $this->object_id_field_for_meta;
}
return array(
'table' => $table,
'object_id_field' => $object_id_field,
'meta_id_field' => $meta_id_field,
);
}