Commit 148302e9 authored by KTP95's avatar KTP95

Solve Bug in join to table without primaryKey

parent dad6618e
......@@ -17,7 +17,7 @@
* @method mixed paginate (int $page, array $fields)
* @method dbObject query ($query, $numRows)
* @method dbObject rawQuery ($query, $bindParams, $sanitize)
* @method dbObject join (string $objectName, string $key, string $joinType)
* @method dbObject join (string $objectName, string $key, string $joinType, string $primaryKey)
* @method dbObject with (string $objectName)
* @method dbObject groupBy (string $groupByField)
* @method dbObject orderBy ($orderByField, $orderbyDirection, $customFields)
......@@ -391,15 +391,19 @@ class dbObject {
* @param string $objectName Object Name
* @param string $key Key for a join from primary object
* @param string $joinType SQL join type: LEFT, RIGHT, INNER, OUTER
* @param string $primaryKey SQL join On Second primaryKey
*
* @return dbObject
*/
private function join ($objectName, $key = null, $joinType = 'LEFT') {
private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey = null) {
$joinObj = new $objectName;
if (!$key)
$key = $objectName . "id";
if (!$primaryKey)
$primaryKey = $joinObj->primaryKey;
$joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " .
MysqliDb::$prefix . "{$joinObj->dbTable}.{$joinObj->primaryKey}";
MysqliDb::$prefix . "{$joinObj->dbTable}.{$primaryKey}";
$this->db->join ($joinObj->dbTable, $joinStr, $joinType);
return $this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment