我在节点和url_alias中都有字段“language”。 当我进行转储时,第二个“语言”变量会覆盖第一个。 我如何识别这两个变量?
$string = "SELECT * FROM {node} as node " .
" LEFT JOIN {url_alias} as url " .
" ON url.src = CONCAT('node/', node.nid) " .
" ORDER BY node.type , node.nid " ;
$result= db_query($string);
while ($row = db_fetch_object($result)){
echo $row->language;
var_dump($row);
答案 0 :(得分:6)
在SELECT
子句中明确指定列名,而不是使用*
,并为任何重复的列名提供别名。如,
SELECT node.nid,
node.language as NodeLanguage,
url.language as UrlLanguage
FROM {node} as node
LEFT JOIN {url_alias} as url
ON url.src = CONCAT('node/', node.nid)
ORDER BY node.type , node.nid