Files
roi-theme/wp-content/plugins/wp-marketing-automations/includes/db/tables/bwfan-db-tables-base.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

83 lines
1.7 KiB
PHP
Executable File

<?php
abstract class BWFAN_DB_Tables_Base {
public $table_name = '';
public $db_errors = '';
public $max_index_length = 191;
public $collation = null;
/**
* Checking table exists or not
*
* @return bool
*/
public function is_exists() {
global $wpdb;
return ! empty( $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}$this->table_name'" ) ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
/**
* Check missing columns and return missing ones only
*
* @return array
*/
public function check_missing_columns() {
global $wpdb;
/** Get defined columns */
$columns = $this->get_columns();
/** Get columns from db */
$db_columns = $wpdb->get_results( "DESCRIBE {$wpdb->prefix}$this->table_name", ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$result = array_diff( $columns, array_column( $db_columns, 'Field' ) );
sort( $result );
return $result;
}
public function get_columns() {
return [];
}
/**
* Create table
*
* @return void
*/
public function create_table() {
global $wpdb;
$sql = $this->get_create_table_query();
if ( empty( $sql ) ) {
return;
}
dbDelta( $sql );
if ( ! empty( $wpdb->last_error ) ) {
$this->db_errors = $this->table_name . ' create table method triggered an error - ' . $wpdb->last_error;
}
}
public function get_create_table_query() {
return '';
}
public function get_collation() {
if ( ! is_null( $this->collation ) ) {
return $this->collation;
}
global $wpdb;
$collate = '';
if ( $wpdb->has_cap( 'collation' ) ) {
$collate = $wpdb->get_charset_collate();
}
$this->collation = $collate;
return $collate;
}
}