HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/lcc.kaunokolegija.lt/wp-content/plugins/codepress-admin-columns/classes/Storage/Table.php
<?php

declare(strict_types=1);

namespace AC\Storage;

use LogicException;

abstract class Table
{

    public function get_timestamp_format(): string
    {
        return 'Y-m-d H:i:s';
    }

    public function exists(): bool
    {
        global $wpdb;

        $query = $wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($this->get_name()));

        return $wpdb->get_var($query) === $this->get_name();
    }

    public function create(): bool
    {
        global $wpdb;

        if ( $this->exists()) {
            throw new LogicException(sprintf('Table %s does already exist', $this->get_name()));
        }

        return $wpdb->query($this->get_schema()) === true;
    }

    /**
     * Return full name including WordPress database prefix
     */
    abstract public function get_name(): string;

    abstract public function get_schema(): string;

}