Select::JoinAdd

Add a join to relationship

Sintaxe

namespace ProtocolLive\PhpLiveDb;
use ProtocolLive\PhpLiveDb\Enums\Joins;

/**

 */
final class Select{
public function JoinAdd(
string|UnitEnum $Table,
string|null|UnitEnum $Using = null,
string|null $On = null,
Joins $Type = Joins::Left
):self;
}
Parameters

$Table - The table name. Can be specify an alias;

$Using - The SQL "using" relationship field;

$On - The SQL "on" relationship field;

$Type - The relationship type;

See more

- Joins

Examples

$consult = $Db->Select('users');
$consult->JoinAdd('socialmedias', 'user_id');
$consult->Run();
//select * from users left join socialmedias using('user_id')

$consult = $Db->Select('users');
$consult->JoinAdd('socialmedias', On: 'users.id=socialmedias.user_id');
$consult->Run();
//select * from users left join socialmedias on users.id=socialmedias.user_id

$consult = $Db->Select('users');
$consult->JoinAdd('socialmedias', 'user_id', Type: Joins::Inner);
$consult->Run();
//select * from users inner join socialmedias using('user_id')