Skip to main content
deleted 543 characters in body
Source Link
Andy
  • 5k
  • 24
  • 37

Completely untestedI couldn't quite wrap my head around those queries in your last comment, just whatbut instead I thought made sense by checkingtried exploring how Views does between operations. Check out add_where and set_where_group.

I'm assuming Viewsdb_or() which is ok with a where group with a single itemused by (just cos it makes the code a little tidier imho)views_handler_filter_numeric::op_between() - if not it's easy to modifyI think that will do it.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}

Completely untested, just what I thought made sense by checking out add_where and set_where_group.

I'm assuming Views is ok with a where group with a single item (just cos it makes the code a little tidier imho) - if not it's easy to modify.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}

I couldn't quite wrap my head around those queries in your last comment, but instead I tried exploring how Views does between operations. Check out db_or() which is used by views_handler_filter_numeric::op_between() - I think that will do it.

added 148 characters in body
Source Link
Andy
  • 5k
  • 24
  • 37

Completely untested, just what I thought made sense by checking out add_where and set_where_group.

I'm assuming Views is ok with a where group with a single item (just cos it makes the code a little tidier imho) - if not it's easy to modify.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}

Completely untested, just what I thought made sense by checking out add_where and set_where_group.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}

Completely untested, just what I thought made sense by checking out add_where and set_where_group.

I'm assuming Views is ok with a where group with a single item (just cos it makes the code a little tidier imho) - if not it's easy to modify.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}
Source Link
Andy
  • 5k
  • 24
  • 37

Completely untested, just what I thought made sense by checking out add_where and set_where_group.

$new_group = $this->query->set_where_group('OR', NULL, 'where');
$not_in = ($this->operator != '=');
$value = vms_get_current_mlid();
$this->query->add_where(
  $new_group,
  $this->real_field,
  $value,
  $this->operator = $not_in ? 'NOT IN' : 'IN'
);

if ($not_in) {
  $this->query->add_where(
    $new_group,
    $this->real_field,
    $value,
    'IS NULL'
  );
}