Join - adampatterson/Dingo-Framework GitHub Wiki

Dingo supports basic JOIN queries. Suppose you have two tables, @users and @friends, that have the following rows:

id name
1 Evan
2 Joe
3 Bob
user friend
1 2
2 1
1 3

You could run a simple JOIN query on these tables like so:


// Select the users table
$table = db('mytable');

$res = $table->select('*')
            ->where('id','=',1)
            ->join('friends')
            ->on('users.id','=','friends.user')
            ->execute();

print_r($res);

Notice the only difference between this query and a regular select is the addition of the @join() an @on() methods. The above would display something like the following:


Array
(
    [0] => Array
        (
            [id] => 1
            [name] => Evan
            [user] => 1
            [friend] => 2
        )

    [1] => Array
        (
            [id] => 1
            [name] => Evan
            [user] => 1
            [friend] => 3
        )

)
⚠️ **GitHub.com Fallback** ⚠️