Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.9
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Sep 2010 at 13:17 UTC
Updated:
27 Sep 2010 at 19:30 UTC
Hi
I want to implement such code
SELECT node.nid AS nid, somesqlfun(mytable.field1, mytable.field2) AS myfield
FROM node node
INNER JOIN mytable ON node.nid=mytable.nid
for this I use such php-code
function mymodule_views_data() {
$data['mymodule']['table']['group'] = t('My Module');
$data['mymodule']['table']['join']['node'] = array(
'type' => 'INNER',
'left_table' => 'node',
'left_field' => 'nid',
'table' => 'mytable',
'field' => 'nid',
);
$data['mymodule']['myfield'] = array(
'real field' => 'somesqlfun(mytable.field1, mytable.field2)',
'title' => t('My field'),
'help' => t('My field description'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => true,
),
);
}
as result I get wrong SQL query
SELECT node.nid AS nid, mytable.somesqlfun(mytable.field1, mytable.field2) AS myfield
FROM node node
INNER JOIN mytable ON node.nid=mytable.nid
How I must change $data array in hook_views_data() to correct?
Comments
Comment #1
kalx commentedSome notes. Need solution without write new handler class for each SQL function. May be only ONE handler class for worj with any SQL function.
Comment #2
dawehnerIf you want to use sql formula you have to write your own field handler.