Quantcast
Channel: Question and Answer » hook-views-query-alter
Viewing all articles
Browse latest Browse all 26

View query alter joins view_joins construct() with condition

$
0
0

We are trying to alter view query, by joining table with extra condition related to other table in the query to avoid duplicate,

$join2 = new views_join;
$join2->construct('mls_state', 'data_field_mls', 'mls_value', 'mls_sid');
$join2->extra = array(array('table' => 'mls_state', 'field' => 'state_code', 'operator' => '=', 'value' => 'data_field_state.state_value'));
$view->query->add_relationship('mls_state',$join2,'data_field_mls');

But in view it default takes the value in quotes
Result

LEFT JOIN {mls_state} mls_state ON data_field_mls.mls_value = mls_state.mls_sid AND mls_state.state_code = 'data_field_state.state_value'

How would we check condition with other referenced table fields value?


Viewing all articles
Browse latest Browse all 26

Latest Images

Trending Articles



Latest Images