我试图为显示内容创建一个块,但出现以下错误:
user warning: Column 'nid' in field list is ambiguous query: SELECT nid, title FROM node nd LEFT JOIN content_type_efemerides cte ON ( nd.nid = cte.nid ) WHERE type = '0' AND field_efemerides_fecha_value = '1' in D:\Webserver\htdocs\intranet\sites\all\modules\efemerides_form\efemerides_form.module on line 12.
第12行有以下代码:
8 $today = getdate();
9 $type = "efemerides";
10
11 $query = "SELECT nid, title FROM {node} nd LEFT JOIN {content_type_efemerides} cte ON ( nd.nid = cte.nid ) WHERE type = '%d' AND field_efemerides_fecha_value = '%d'";
12 $query_result = db_query($query, $type, $today);
最佳答案
select语句中的nid
不明确(如错误消息所述),您只需使用表别名限定它:
$query = "SELECT nd.nid, nd.title FROM {node} nd LEFT JOIN {content_type_efemerides} cte ON ( nd.nid = cte.nid ) WHERE type = '%s' AND field_efemerides_fecha_value = '%s'";
字符串替换也应该使用
%s
而不是%d
(%d
表示小数)关于php - 字段列表中的列“nid”在Drupal6中是模棱两可的查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7889622/