Cannot join two fields from my table to one base table

I've created a module with a table that has the following fields

+------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+-------+
| type | varchar(128) | NO | PRI | | |
| tid_group | int(10) unsigned | NO | PRI | 0 | |
| tid | int(10) unsigned | NO | PRI | 0 | |
| node_count | int(10) unsigned | NO | | 0 | |
+------------+------------------+------+-----+---------+-------+

Fields tid_group and tid are taxonomy tid's. To expose these fields I want them both to link to the tid field in term_data.

From the syntax that I've looked at this will cause one array element for the first field, only to be overridden by the second. See below. It seems I have to use the exact keys for both fields.

  $data['taxonomy_hash_count']['table']['join']['term_data'] = array(
        'left_field' => 'tid',
      'field' => 'tid_group'
  );
$data['taxonomy_hash_count']['table']['join']['term_data'] = array(
        'left_field' => 'tid',
      'field' => 'tid'
    );

How will I be able to do this? Is it perhaps possible to create two ..views.inc files that exposes each seperately?

Any input would be much appreciated. I've created this module so that the number of terms grouped by another category can be saved in nodeapi as there will be millions of records. This will be much more efficient, doing queries from the database will kill the server.

In my case I want to know how many nodes have a certain classification (e.g household, office) per region/province.

Login to post comments