Hello,
I'm creating a module in which I'd like to use TableSort, but I'm having some trouble creating the DBTNG query object.
This works:
$header = array(
//array('data' => t('Profile Type'), 'field' => 'pt.label'),
array('data' => t('ID'), 'field' => 'pr.profile_id', 'sort' => 'ASC'),
array('data' => t('Path'), 'field' => 'pr.path', 'sort' => 'ASC'),
);
$query = db_select('profile2_regpath', 'pr')
//->join('profile_type', 'pt', 'pr.profile_id = pt.id')
->extend('TableSort')
->fields('pr', array('profile_id', 'path'))
//->fields('pt', array('id', 'label'))
->orderByHeader($header); // tell the query object how to find the header information.
$result = $query->execute();
However, I need to query two tables and display the results of the join when generating the table. Adding in the join logic leaves me with a WSOD:
<?php
$header = array(
array('data' => t('Profile Type'), 'field' => 'pt.label'),
array('data' => t('ID'), 'field' => 'pr.profile_id', 'sort' => 'ASC'),
array('data' => t('Path'), 'field' => 'pr.path', 'sort' => 'ASC'),
);
$query = db_select('profile2_regpath', 'pr')
->join('profile_type', 'pt', 'pr.profile_id = pt.id')
->extend('TableSort')
->fields('pr', array('profile_id', 'path'))
->fields('pt', array('id', 'label'))