fuel / orm

Fuel PHP Framework - Fuel v1.x ORM
http://fuelphp.com/docs/packages/orm/intro.html
152 stars 96 forks source link

Orm Cannot set 'or' condition for $_conditions. #413

Closed ysshir closed 7 years ago

ysshir commented 7 years ago

I would like to create something below

class Model_Test extends \Orm\Model
{
  ...
  protected static $_conditions = [
    'where' => [
      [ [ 'deleted' => null ], 'or' => [ 'deleted', 0 ] ],
    ],
  ];
  ...
}

But I cannot get correct result. So I read source code and, I think default condition should be treated with _parse_where_array() instead of where() in Query class.

or Orm\Query::where() should use _parse_where_array() if the first argument is array

public function where()
{
   $condition = func_get_args();
   if (is_array(reset($condition)))
   {
       return $this->_parse_where_array(reset($condition));    
       }
   return $this->_where($condition);
}

thanks.

ysshir commented 7 years ago

thanks a lot !