Automattic\WooCommerce\Blocks
Installer::maybe_create_table() protected WC 1.0
Create database table, if it doesn't already exist.
Based on admin/install-helper.php maybe_create_table function.
{} Это метод класса: Installer{}
Хуков нет.
Возвращает
true|false
. False on error, true if already exists or success.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->maybe_create_table( $table_name, $create_sql );
- $table_name(строка) (обязательный)
- Database table name.
- $create_sql(строка) (обязательный)
- Create database table SQL.
Код Installer::maybe_create_table() Installer::maybe create table WC 5.2.2
protected function maybe_create_table( $table_name, $create_sql ) {
global $wpdb;
if ( in_array( $table_name, $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ), 0 ), true ) ) {
return true;
}
$wpdb->query( $create_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
return in_array( $table_name, $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ), 0 ), true );
}