diff --git a/MysqliDb.php b/MysqliDb.php index f4bfa6d3..4f9d5f32 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -887,7 +887,7 @@ public function orderBy($orderByField, $orderbyDirection = "DESC", $customFields if (is_array($customFields)) { foreach ($customFields as $key => $value) { - $customFields[$key] = preg_replace("/[^-a-z0-9\.\(\),_`]+/i", '', $value); + $customFields[$key] = preg_replace("/[^-a-z0-9\.\(\),_` ]+/i", '', $value); } $orderByField = 'FIELD (' . $orderByField . ', "' . implode('","', $customFields) . '")'; @@ -1265,7 +1265,11 @@ public function _buildDataPairs($tableData, $tableColumns, $isInsert) $value = $tableData[$column]; if (!$isInsert) { - $this->_query .= "`" . $column . "` = "; + if(strpos($column,'.')===false) { + $this->_query .= "`" . $column . "` = "; + } else { + $this->_query .= str_replace('.','.`',$column) . "` = "; + } } // Subquery value diff --git a/dbObject.php b/dbObject.php index 29fafdd4..ef6b70df 100644 --- a/dbObject.php +++ b/dbObject.php @@ -401,11 +401,15 @@ private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey $joinObj = new $objectName; if (!$key) $key = $objectName . "id"; - if (!$primaryKey) - $primaryKey = $joinObj->primaryKey; + + if (!$primaryKey) + $primaryKey = MysqliDb::$prefix . $joinObj->dbTable . "." . $joinObj->primaryKey; - $joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " . - MysqliDb::$prefix . "{$joinObj->dbTable}.{$primaryKey}"; + if (!strchr ($key, '.')) + $joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " . $primaryKey; + else + $joinStr = MysqliDb::$prefix . "{$key} = " . $primaryKey; + $this->db->join ($joinObj->dbTable, $joinStr, $joinType); return $this; }