专栏“nid”在 Drupal6 中,字段列表中的查询不明确
我正在尝试创建一个用于显示内容的块,但收到此错误:
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);
I'm trying to create a block for display content but I'm getting this error:
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.
Line 12 have this code:
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
select 语句中的
nid
不明确(如错误消息所示),您只需使用表别名对其进行限定:字符串替换也应使用
%s
完成而不是%d
(%d
代表小数)The
nid
in your select statement is ambiguous (as the error message states), you just need to qualify it with a table alias:Also string replacements should be done using
%s
instead of%d
(%d
being for decimals)