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