我正在使用views_query_alter
更改视图查询。在我的查询中,我想要类似的条件
DATE_FORMAT(FROM_UNIXTIME(field_data_field_hiddeneventdate.field_hiddeneventdate_value), '%m') = '06'
。
但是当我尝试
$condition = array('field' => "DATE_FORMAT(FROM_UNIXTIME(field_data_field_hiddeneventdate.field_hiddeneventdate_value), '%m')",
'value' => date('%Y-%m'), //$view->exposed_raw_input['title'],
'operator' => '>=',
);
它生成查询:
SELECT node.title AS node_title, node.nid AS nid, field_data_field_hiddeneventdate.field_hiddeneventdate_value AS node_changed
FROM
{node} node
LEFT JOIN {field_data_field_hiddeneventdate} field_data_field_hiddeneventdate ON node.nid = field_data_field_hiddeneventdate.entity_id AND (field_data_field_hiddeneventdate.entity_type = node AND field_data_field_hiddeneventdate.deleted = 0)
WHERE (( (node.status = '1') AND (node.type IN ('events_meeting')) )AND( (DATE_FORMATFROM_UNIXTIMEfield_data_field_hiddeneventdate.field_hiddeneventdate_valuem >= '%2013-%06') ))
LIMIT 10 OFFSET 0.
但我想要 :
SELECT node.title AS node_title, node.nid AS nid, field_data_field_hiddeneventdate.field_hiddeneventdate_value AS node_changed,
DATE_FORMAT(FROM_UNIXTIME(field_data_field_hiddeneventdate.field_hiddeneventdate_value), '%d-%m-%Y') AS dt
FROM node node
LEFT JOIN field_data_field_hiddeneventdate field_data_field_hiddeneventdate
ON
node.nid = field_data_field_hiddeneventdate.entity_id
AND
(field_data_field_hiddeneventdate.entity_type = 'node'
AND field_data_field_hiddeneventdate.deleted = 0)
WHERE (( (node.status = '1') AND (node.type IN ('events_meeting')) )
AND( DATE_FORMAT(FROM_UNIXTIME(field_data_field_hiddeneventdate.field_hiddeneventdate_value), '%m') = '06'
)
)
LIMIT 10 OFFSET 0;
谁能帮我。