PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / vendor / codesvault / howdy-qb / src / Statement / Table.php

Table.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at vendor/codesvault/howdy-qb/src/Statement/Table.php

55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace CodesVault\Howdyqb\Statement;
4
5 use CodesVault\Howdyqb\Api\TableInterface;
6 use CodesVault\Howdyqb\Utilities;
7 use CodesVault\Howdyqb\Validation\IdentifierValidator;
8
9 class Table implements TableInterface
10 {
11 protected $db;
12 protected $params = [];
13 private $table_name;
14
15 public function __construct($db, string $table_name)
16 {
17 $this->db = $db;
18 $prefix = Utilities::get_db_configs()->prefix;
19 $this->table_name = IdentifierValidator::validateTableName($prefix . $table_name);
20 }
21
22 public function drop()
23 {
24 $sql = 'DROP TABLE ' . $this->table_name;
25 $this->driverExecute($sql);
26 }
27
28 public function dropIfExists()
29 {
30 $sql = 'DROP TABLE IF EXISTS ' . $this->table_name;
31 $this->driverExecute($sql);
32 }
33
34 public function truncate()
35 {
36 $sql = 'TRUNCATE TABLE ' . $this->table_name;
37 $this->driverExecute($sql);
38 }
39
40 private function driverExecute($sql)
41 {
42 $driver = $this->db;
43 if (class_exists('wpdb') && $driver instanceof \wpdb) {
44 return $driver->query($sql);
45 }
46
47 $data = $driver->prepare($sql);
48 try {
49 return $data->execute($this->params);
50 } catch (\Exception $exception) {
51 Utilities::throughException($exception);
52 }
53 }
54 }
55