0

I am trying to put value comparision while creating relationship. When i give direct value that works perfectly fine. but i wanted to pass column name with alias to get required results.

This is working fine

$this->query->add_where(
        $this->options['group'],
        db_and()
          ->condition("class.end_time", 1625047346 , '<=')
    );

output
WHERE ((( (class.end_time <= 1625047346) ))AND ...............

This is not working. it takes alias.column as value

$this->query->add_where(
        $this->options['group'],
        db_and()
          ->condition("class.end_time", "class1.end_time" , '<=')
    );

output
WHERE ((( (class.end_time <= 'class.end_time') ))AND ...............

1 Answer 1

0

I found a solution. I just passed all the conditions as an extra text after join and it works.

This is how I passed text while joining two tables. You can pass extra while constructing join as a fifth parameter.

class mymodule_booking_classes_relationship  extends views_handler_relationship {

    function query() {
    
        $extra = "class.end_time <=  class1.start_time  ";
        $extra .= " or class.start_time >= class1.end_time ";

        $join3 = new views_join;
        $join3->construct('class_table', 'node', 'nid', 'course_id', $extra, 'INNER'); 
        $this->alias = $this->query->add_relationship('class1', $join3, 'class1');

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.