我想写一个SQL查询来查找节点ID(nid),该节点的标题与给定内容类型的给定标题(标题字段值的值)相匹配。我正在尝试以下操作-
function title_ajax_check_duplicate($title, $type) {
$results = db_query("SELECT nid FROM {node} WHERE title = %s AND type = %s ", $title, $type);
if (!empty($results)) {
// This is a duplicate.
return $results;
}
else {
return FALSE;
}
}
I am not able to solve this for a long time. Any help would be much appriciated. Thanks in advance.