dbObject::join PHP Méthode

join() private méthode

Function to join object with another object.
private join ( string $objectName, string $key = null, string $joinType = 'LEFT', string $primaryKey = null ) : dbObject
$objectName string Object Name
$key string Key for a join from primary object
$joinType string SQL join type: LEFT, RIGHT, INNER, OUTER
$primaryKey string SQL join On Second primaryKey
Résultat dbObject
    private function join($objectName, $key = null, $joinType = 'LEFT', $primaryKey = null)
    {
        $joinObj = new $objectName();
        if (!$key) {
            $key = $objectName . "id";
        }
        if (!$primaryKey) {
            $primaryKey = MysqliDb::$prefix . $joinObj->dbTable . "." . $joinObj->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;
    }