Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Conditional join with DB class
  • How can i do conditional join with the db class? \DB::select(
    'photos.user_id','photos.img', 'photos.screened', 'users.id', 'users.username'
    )->from('users')
    ->join('photos', 'LEFT')
    ->on('users.id', '=', 'photos.user_id' AND `photos`.`screened`=1') Is this possible? Thanks.
  • Why not just add a where clause? `photos`.`screened`=1' Here is link in docs: http://fuelphp.com/docs/classes/database/usage.html#filtering
  • got it working with this. ( Thanks jschreuder )
      ->on('users.id', '=', 'photos.user_id')
    ->on('photos.default', '=', DB::expr(1))
    
  • Great!
    Could you update the doc to illustrate this ?
  • Added some clarification to the docs (1.4/develop).

Howdy, Stranger!

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

In this Discussion