Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
OR in where clause
  • Hi, I want to use the array syntax for passing the WHERE clause in Orm::find but I can't figure out how to get ORs in there. Can any one tell me how I have to build the array to get something like:
    (A = 1 OR A = 3) AND active = true

  • Works just like the DB query builder:
            ->where('A', '=', 1)
            ->or_where('B', '=', 2)
        ->where('C', '=', 3)
  • Thanks for your reply. I need to be able to build the query up. Looking at the code it looked to me like something like this should work but I didn't have any luck.
    $where = array(
       'or' => array(

    What is the correct way to go about building the where cause at run time? Thanks
  • The model methods return themselfs so you can chain. Nobody's saying you should do that all in one go
    // this is the same as
            ->where('A', '=', 1)
            ->or_where('B', '=', 2)
         ->where('C', '=', 3)
    // this...
    $q = Model_Example::query();
            ->where('A', '=', 1)
            ->or_where('B', '=', 2)
    $q->where('C', '=', 3);
  • I see. Thank you very much!

Howdy, Stranger!

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

In this Discussion