Skip to content

Commit 6a63f6c

Browse files
committed
dbObject: Do not prefix join object with a table name with it already have one
1 parent fb85c70 commit 6a63f6c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dbObject.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,18 @@ private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey
401401
$joinObj = new $objectName;
402402
if (!$key)
403403
$key = $objectName . "id";
404-
if (!$primaryKey)
404+
405+
if (!$primaryKey)
405406
$primaryKey = $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} = " .
410+
MysqliDb::$prefix . "{$joinObj->dbTable}.{$joinObj->primaryKey}";
411+
} else {
412+
$joinStr = MysqliDb::$prefix . "{$key} = " .
413+
MysqliDb::$prefix . "{$joinObj->dbTable}.{$joinObj->primaryKey}";
414+
}
415+
409416
$this->db->join ($joinObj->dbTable, $joinStr, $joinType);
410417
return $this;
411418
}

0 commit comments

Comments
 (0)