From 5e531f4e15afde793d9a4807448a66512b392b62 Mon Sep 17 00:00:00 2001 From: 0xRenegade Date: Fri, 23 Sep 2022 23:44:01 -0500 Subject: [PATCH] updated MysqliDb class functions to handle prefix properly. --- qrcode/lib/MysqliDb/MysqliDb.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/qrcode/lib/MysqliDb/MysqliDb.php b/qrcode/lib/MysqliDb/MysqliDb.php index d44dca7..b01e8c6 100644 --- a/qrcode/lib/MysqliDb/MysqliDb.php +++ b/qrcode/lib/MysqliDb/MysqliDb.php @@ -727,7 +727,7 @@ class MysqliDb $column = is_array($columns) ? implode(', ', $columns) : $columns; - if (strpos($tableName, '.') === false) { + if (strpos($tableName, '.') === false && strpos($tableName, DATABASE_PREFIX) === false) { $this->_tableName = self::$prefix . $tableName; } else { $this->_tableName = $tableName; @@ -761,6 +761,10 @@ class MysqliDb */ public function getOne($tableName, $columns = '*') { + if (strpos($tableName, '.') === false && strpos($tableName, DATABASE_PREFIX) === false) { + $tableName = DATABASE_PREFIX . $tableName; + } + $res = $this->get($tableName, 1, $columns); if ($res instanceof MysqliDb) { @@ -786,6 +790,12 @@ class MysqliDb */ public function getValue($tableName, $column, $limit = 1) { + error_log('1 '.$tableName); + if (strpos($tableName, '.') === false && strpos($tableName, DATABASE_PREFIX) === false) { + $tableName = DATABASE_PREFIX . $tableName; + } + error_log('2 '.$tableName); + $res = $this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval"); if (!$res) { @@ -832,6 +842,9 @@ class MysqliDb */ public function insertMulti($tableName, array $multiInsertData, array $dataKeys = null) { + if (strpos($tableName, '.') === false && strpos($tableName, DATABASE_PREFIX) === false) { + $tableName = DATABASE_PREFIX . $tableName; + } // only auto-commit our inserts, if no transaction is currently running $autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true); $ids = array();