| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: |
|
| 11: | namespace Opencart\System\Library;
|
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | class DB {
|
| 18: | |
| 19: | |
| 20: |
|
| 21: | private object $adaptor;
|
| 22: |
|
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: |
|
| 36: | public function __construct(string $adaptor, string $hostname, string $username, string $password, string $database, string $port = '', string $ssl_key = '', string $ssl_cert = '', string $ssl_ca = '') {
|
| 37: | $class = 'Opencart\System\Library\DB\\' . $adaptor;
|
| 38: |
|
| 39: | if (class_exists($class)) {
|
| 40: | $this->adaptor = new $class($hostname, $username, $password, $database, $port, $ssl_key, $ssl_cert, $ssl_ca);
|
| 41: | } else {
|
| 42: | throw new \Exception('Error: Could not load database adaptor ' . $adaptor . '!');
|
| 43: | }
|
| 44: | }
|
| 45: |
|
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: |
|
| 53: | public function query(string $sql) {
|
| 54: | return $this->adaptor->query($sql);
|
| 55: | }
|
| 56: |
|
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: |
|
| 64: | public function escape(string $value): string {
|
| 65: | return $this->adaptor->escape($value);
|
| 66: | }
|
| 67: |
|
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: |
|
| 75: | public function countAffected(): int {
|
| 76: | return $this->adaptor->countAffected();
|
| 77: | }
|
| 78: |
|
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: |
|
| 86: | public function getLastId(): int {
|
| 87: | return $this->adaptor->getLastId();
|
| 88: | }
|
| 89: |
|
| 90: | |
| 91: | |
| 92: | |
| 93: | |
| 94: | |
| 95: | |
| 96: |
|
| 97: | public function isConnected(): bool {
|
| 98: | return $this->adaptor->isConnected();
|
| 99: | }
|
| 100: | }
|
| 101: | |