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 / QueryFactory.php

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

95 lines 2.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;
4
5 use CodesVault\Howdyqb\Api\SelectInterface;
6 use CodesVault\Howdyqb\Statement\Alter;
7 use CodesVault\Howdyqb\Statement\Create;
8 use CodesVault\Howdyqb\Statement\Delete;
9 use CodesVault\Howdyqb\Statement\Table;
10 use CodesVault\Howdyqb\Statement\Insert;
11 use CodesVault\Howdyqb\Statement\Select;
12 use CodesVault\Howdyqb\Statement\Update;
13
14 class QueryFactory
15 {
16 protected $db = null;
17 protected static $driver = 'pdo';
18 private static $config;
19
20 public static function getDriver()
21 {
22 return static::$driver;
23 }
24
25 public function __construct($driver = 'pdo')
26 {
27 if ($this->db) return;
28
29 static::$driver = $driver;
30
31 if ('pdo' === $driver) {
32 $this->db = Connect::pdo();
33 } elseif ('wpdb' === $driver) {
34 global $wpdb;
35 $this->db = $wpdb;
36 }
37 }
38
39 /**
40 * Set manula connection
41 *
42 * @param array $configs
43 * @param string $driver
44 * @return CodesVault\Howdyqb\DB
45 */
46 public static function setConnection($configs = [], $driver = 'pdo')
47 {
48 if (empty($configs)) {
49 $configs = Connect::setManualConnection($configs);
50 }
51 static::$config = $configs;
52 return new DB($driver);
53 }
54
55 protected function selectQuery(): SelectInterface
56 {
57 return new Select($this->db);
58 }
59
60 protected function insertQuery(string $table_name, array $data)
61 {
62 return new Insert($this->db, $table_name, $data);
63 }
64
65 protected function createQuery(string $table_name)
66 {
67 return new Create($this->db, $table_name);
68 }
69
70 protected function alterQuery(string $table_name)
71 {
72 return new Alter($this->db, $table_name);
73 }
74
75 protected function updateQuery(string $table_name, array $data)
76 {
77 return new Update($this->db, $table_name, $data);
78 }
79
80 protected function deleteQuery(string $table_name)
81 {
82 return new Delete($this->db, $table_name);
83 }
84
85 protected function tableQuery(string $table_name)
86 {
87 return new Table($this->db, $table_name);
88 }
89
90 public static function getConfig()
91 {
92 return static::$config;
93 }
94 }
95