Skip to content

Commit 3df726d

Browse files
committed
Merge pull request #472 from avbdr/master
fixes
2 parents a62e491 + ff09f83 commit 3df726d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

MysqliDb.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ public function orderBy($orderByField, $orderbyDirection = "DESC", $customFields
887887

888888
if (is_array($customFields)) {
889889
foreach ($customFields as $key => $value) {
890-
$customFields[$key] = preg_replace("/[^-a-z0-9\.\(\),_`]+/i", '', $value);
890+
$customFields[$key] = preg_replace("/[^-a-z0-9\.\(\),_` ]+/i", '', $value);
891891
}
892892

893893
$orderByField = 'FIELD (' . $orderByField . ', "' . implode('","', $customFields) . '")';
@@ -1265,7 +1265,11 @@ public function _buildDataPairs($tableData, $tableColumns, $isInsert)
12651265
$value = $tableData[$column];
12661266

12671267
if (!$isInsert) {
1268-
$this->_query .= "`" . $column . "` = ";
1268+
if(strpos($column,'.')===false) {
1269+
$this->_query .= "`" . $column . "` = ";
1270+
} else {
1271+
$this->_query .= str_replace('.','.`',$column) . "` = ";
1272+
}
12691273
}
12701274

12711275
// Subquery value

dbObject.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,15 @@ private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey
401401
$joinObj = new $objectName;
402402
if (!$key)
403403
$key = $objectName . "id";
404-
if (!$primaryKey)
405-
$primaryKey = $joinObj->primaryKey;
404+
405+
if (!$primaryKey)
406+
$primaryKey = MysqliDb::$prefix . $joinObj->dbTable . "." . $joinObj->primaryKey;
406407

407-
$joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " .
408-
MysqliDb::$prefix . "{$joinObj->dbTable}.{$primaryKey}";
408+
if (!strchr ($key, '.'))
409+
$joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " . $primaryKey;
410+
else
411+
$joinStr = MysqliDb::$prefix . "{$key} = " . $primaryKey;
412+
409413
$this->db->join ($joinObj->dbTable, $joinStr, $joinType);
410414
return $this;
411415
}

0 commit comments

Comments
 (0)