[support] Views2: Integrate custom table using two key identifiers

Hadubard hadubard at gmail.com
Wed Sep 12 16:03:53 UTC 2012


Hi,

is it possible to integrate a custom table into the views2 world that needs a two column match for the join?

The code I have right now (in a hook_views_data implementation) is this:
$data['custom_table']['table']['join'] = array(
    'users' => array(
      'left_table' => 'other_custom_table',
      'left_field' => 'field_1',
      'field' => 'field_1',        
    ),
  );

This is working for the moment, but I need to bind in another join criterion on another field, in pseudo-code that would be something along these lines:
$data['custom_table']['table']['join'] = array(
  'users' => array(
    array(
      'left_table' => 'other_custom_table',
      'left_field' => 'field_1',
      'field' => 'field_1',
    ),
    array(
    'left_table' => 'other_custom_table',
    'left_field' => 'field_2',
    'field' => 'field_2',        
  ),
  ),
);

The resulting query would resemble this:
SELECT ...
FROM cutomer_table c1
LEFT JOIN other_custom_table c2 ON (c1.field_1 = c2.field_1 AND c1.field_2 = c2.field_2)

Is this possible with views2?

Thanks for any thoughts,
best regards,
berliner


More information about the support mailing list