| 1 |
<?php |
| 2 |
|
| 3 |
namespace MailPoet\Config; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) exit; |
| 6 |
|
| 7 |
|
| 8 |
use MailPoetVendor\Idiorm\ORM; |
| 9 |
use PDO; |
| 10 |
|
| 11 |
class Database { |
| 12 |
public function init(PDO $pdo) { |
| 13 |
ORM::setDb($pdo); |
| 14 |
$this->setupLogging(); |
| 15 |
$this->defineTables(); |
| 16 |
} |
| 17 |
|
| 18 |
public function setupLogging() { |
| 19 |
ORM::configure('logging', WP_DEBUG); |
| 20 |
} |
| 21 |
|
| 22 |
public function defineTables() { |
| 23 |
if (!defined('MP_SETTINGS_TABLE')) { |
| 24 |
define('MP_SETTINGS_TABLE', Env::$dbPrefix . 'settings'); |
| 25 |
define('MP_SEGMENTS_TABLE', Env::$dbPrefix . 'segments'); |
| 26 |
define('MP_FORMS_TABLE', Env::$dbPrefix . 'forms'); |
| 27 |
define('MP_CUSTOM_FIELDS_TABLE', Env::$dbPrefix . 'custom_fields'); |
| 28 |
define('MP_SUBSCRIBERS_TABLE', Env::$dbPrefix . 'subscribers'); |
| 29 |
define('MP_SUBSCRIBER_SEGMENT_TABLE', Env::$dbPrefix . 'subscriber_segment'); |
| 30 |
define('MP_SUBSCRIBER_CUSTOM_FIELD_TABLE', Env::$dbPrefix . 'subscriber_custom_field'); |
| 31 |
define('MP_SUBSCRIBER_IPS_TABLE', Env::$dbPrefix . 'subscriber_ips'); |
| 32 |
define('MP_NEWSLETTER_SEGMENT_TABLE', Env::$dbPrefix . 'newsletter_segment'); |
| 33 |
define('MP_SCHEDULED_TASKS_TABLE', Env::$dbPrefix . 'scheduled_tasks'); |
| 34 |
define('MP_SCHEDULED_TASK_SUBSCRIBERS_TABLE', Env::$dbPrefix . 'scheduled_task_subscribers'); |
| 35 |
define('MP_SENDING_QUEUES_TABLE', Env::$dbPrefix . 'sending_queues'); |
| 36 |
define('MP_NEWSLETTERS_TABLE', Env::$dbPrefix . 'newsletters'); |
| 37 |
define('MP_NEWSLETTER_TEMPLATES_TABLE', Env::$dbPrefix . 'newsletter_templates'); |
| 38 |
define('MP_NEWSLETTER_OPTION_FIELDS_TABLE', Env::$dbPrefix . 'newsletter_option_fields'); |
| 39 |
define('MP_NEWSLETTER_OPTION_TABLE', Env::$dbPrefix . 'newsletter_option'); |
| 40 |
define('MP_NEWSLETTER_LINKS_TABLE', Env::$dbPrefix . 'newsletter_links'); |
| 41 |
define('MP_NEWSLETTER_POSTS_TABLE', Env::$dbPrefix . 'newsletter_posts'); |
| 42 |
define('MP_STATISTICS_NEWSLETTERS_TABLE', Env::$dbPrefix . 'statistics_newsletters'); |
| 43 |
define('MP_STATISTICS_CLICKS_TABLE', Env::$dbPrefix . 'statistics_clicks'); |
| 44 |
define('MP_STATISTICS_OPENS_TABLE', Env::$dbPrefix . 'statistics_opens'); |
| 45 |
define('MP_STATISTICS_UNSUBSCRIBES_TABLE', Env::$dbPrefix . 'statistics_unsubscribes'); |
| 46 |
define('MP_STATISTICS_FORMS_TABLE', Env::$dbPrefix . 'statistics_forms'); |
| 47 |
define('MP_STATISTICS_WOOCOMMERCE_PURCHASES_TABLE', Env::$dbPrefix . 'statistics_woocommerce_purchases'); |
| 48 |
define('MP_MAPPING_TO_EXTERNAL_ENTITIES_TABLE', Env::$dbPrefix . 'mapping_to_external_entities'); |
| 49 |
define('MP_LOG_TABLE', Env::$dbPrefix . 'log'); |
| 50 |
define('MP_STATS_NOTIFICATIONS_TABLE', Env::$dbPrefix . 'stats_notifications'); |
| 51 |
define('MP_USER_FLAGS_TABLE', Env::$dbPrefix . 'user_flags'); |
| 52 |
define('MP_FEATURE_FLAGS_TABLE', Env::$dbPrefix . 'feature_flags'); |
| 53 |
define('MP_DYNAMIC_SEGMENTS_FILTERS_TABLE', Env::$dbPrefix . 'dynamic_segment_filters'); |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|