|
17 | 17 | * @method mixed paginate (int $page, array $fields)
|
18 | 18 | * @method dbObject query ($query, $numRows)
|
19 | 19 | * @method dbObject rawQuery ($query, $bindParams, $sanitize)
|
20 |
| - * @method dbObject join (string $objectName, string $key, string $joinType) |
| 20 | + * @method dbObject join (string $objectName, string $key, string $joinType, string $primaryKey) |
21 | 21 | * @method dbObject with (string $objectName)
|
22 | 22 | * @method dbObject groupBy (string $groupByField)
|
23 | 23 | * @method dbObject orderBy ($orderByField, $orderbyDirection, $customFields)
|
@@ -391,15 +391,19 @@ private function with ($objectName) {
|
391 | 391 | * @param string $objectName Object Name
|
392 | 392 | * @param string $key Key for a join from primary object
|
393 | 393 | * @param string $joinType SQL join type: LEFT, RIGHT, INNER, OUTER
|
| 394 | + * @param string $primaryKey SQL join On Second primaryKey |
394 | 395 | *
|
395 | 396 | * @return dbObject
|
396 | 397 | */
|
397 |
| - private function join ($objectName, $key = null, $joinType = 'LEFT') { |
| 398 | + private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey = null) { |
398 | 399 | $joinObj = new $objectName;
|
399 | 400 | if (!$key)
|
400 | 401 | $key = $objectName . "id";
|
| 402 | + if (!$primaryKey) |
| 403 | + $primaryKey = $joinObj->primaryKey; |
| 404 | + |
401 | 405 | $joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " .
|
402 |
| - MysqliDb::$prefix . "{$joinObj->dbTable}.{$joinObj->primaryKey}"; |
| 406 | + MysqliDb::$prefix . "{$joinObj->dbTable}.{$primaryKey}"; |
403 | 407 | $this->db->join ($joinObj->dbTable, $joinStr, $joinType);
|
404 | 408 | return $this;
|
405 | 409 | }
|
|
0 commit comments