relationshipJoin()

relationshipJoin($linkName, $tableLeft, $fieldLeft = null, $fieldRight = null, $operator = '=', $joinType = 'JOIN', $tableRight = null)

Works like join() but for getRelationship() call
@param String $linkName
@param String $tableLeft
@param String $fieldLeft
@param String $fieldRight
@param String $operator
@param String $joinType
@param String $tableRight
@return PhpBURN_Core

Params


$linkName
Is the name of the relationship that will receive the commands

$tableName
Name of the table that will receive the JOIN

$fieldLeft
The field form left side of the join ON statement

$fieldRight
Value or field on the right side of ON statement

$operator (optional)
The operator for ON statment

$joinType (optional)
JOIN, INNER JOIN, OUTTER JOIN, LEFT JOIN, RIGHT JOIN

$tableRight (optional)
When you want to use $fieldRight as a table field you should specify this param with the right table to be attached to $fieldRight field

Explanation


Many times just simple selects aren’t enough for us to do our work, so join is a real friend but many developers don’t know or are afraid of use JOIN, so now your problems are solved. Now we can do it EVEN WHEN we are calling Relationships, isn’t that cool?

Let’s see usage examples of this method:

$user = new Users();
$user->get(1);

$user->relationshipJoin('albums','pictures','album','id_album','=','LEFT JOIN','albums');
$user->getRelationship('albums');

That will perform a LEFT JOIN between your already mapped ‘albums’ into ‘pictures’ database table.

For more tips of it’s usage see join() in www.phpburn.com/documentation/orm/join