0

我通过获取电子邮件以编程方式创建节点。我在哪里拆分邮件的主题,以便为特定的组和节点的标题创建它。现在我想通过组的描述来获取 group_id 并为其编写查询,但它不起作用。让我在这里粘贴代码..

list($group_name, $title_text) = explode(', ', $title);
$query = "SELECT * FROM {og} WHERE og_description = ' ".$group_name." ' ";
$group_details = db_query($query); 
while ($group = db_fetch_object($group_details)) {              
   $gid = $group->nid;
}
echo $gid;

echo $gid什么都不给。虽然$group_name = 'Logo design'&gid = 1442在表中。我在这里有什么遗漏吗?

4

2 回答 2

0

查看以下两页,此处给出的示例未在查询中的占位符周围使用单引号($group_name - 在您的示例中)。

http://drupal.org/node/310072

其中一行说“请注意,无论其类型如何,都不应转义或引用占位符”。

http://drupal.org/node/1407528

于 2012-06-14T11:59:12.057 回答
0

我已经解决了。这是答案:-

$title = "ED's presentation, This content is for ed's presenation"; //This is the subject of the mail, which I am fetching.

list($group_name, $title_text) = explode(', ', $title);
$query = "SELECT nid FROM {og} WHERE og_description = '".$group_name."'";
$group_details = db_query($query);
while ($group = db_fetch_object($group_details)) {
{
  $gid = $group->nid;
}

谢谢 :)

于 2012-06-15T05:39:36.063 回答