updated MysqliDb class functions to handle prefix properly.
This commit is contained in:
@@ -727,7 +727,7 @@ class MysqliDb
|
|||||||
|
|
||||||
$column = is_array($columns) ? implode(', ', $columns) : $columns;
|
$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;
|
$this->_tableName = self::$prefix . $tableName;
|
||||||
} else {
|
} else {
|
||||||
$this->_tableName = $tableName;
|
$this->_tableName = $tableName;
|
||||||
@@ -761,6 +761,10 @@ class MysqliDb
|
|||||||
*/
|
*/
|
||||||
public function getOne($tableName, $columns = '*')
|
public function getOne($tableName, $columns = '*')
|
||||||
{
|
{
|
||||||
|
if (strpos($tableName, '.') === false && strpos($tableName, DATABASE_PREFIX) === false) {
|
||||||
|
$tableName = DATABASE_PREFIX . $tableName;
|
||||||
|
}
|
||||||
|
|
||||||
$res = $this->get($tableName, 1, $columns);
|
$res = $this->get($tableName, 1, $columns);
|
||||||
|
|
||||||
if ($res instanceof MysqliDb) {
|
if ($res instanceof MysqliDb) {
|
||||||
@@ -786,6 +790,12 @@ class MysqliDb
|
|||||||
*/
|
*/
|
||||||
public function getValue($tableName, $column, $limit = 1)
|
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");
|
$res = $this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval");
|
||||||
|
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
@@ -832,6 +842,9 @@ class MysqliDb
|
|||||||
*/
|
*/
|
||||||
public function insertMulti($tableName, array $multiInsertData, array $dataKeys = null)
|
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
|
// only auto-commit our inserts, if no transaction is currently running
|
||||||
$autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true);
|
$autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true);
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|||||||
Reference in New Issue
Block a user