Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DB join on with a value problem
  • Hi I want to create a query like this:

    $user_id = 5;
    $query = \DB::select('companies.*', \DB::expr('IF(test.user_id,"YES","NO") AS connected'))
                ->join('test', 'LEFT')
                ->on('test.company_id', '=', '')
                ->on('test.user_id', '=', $user_id)
                ->order_by('connected', 'DESC')
                ->order_by('companies.count_blogs', 'DESC')

    But this gives a problem with this line:
    ->on('test.user_id', '=', $user_id)

    I want the join to look like this: LEFT JOIN test ON ( AND test.user_id=5)

    it seems it cannot bind a variable to a join, only columns...
  • created an issue on github for it:
  • it seems this works:

    ->on('test.user_id', '=', \DB::expr($user_id))

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion