以下作品......
global $user;
$items = array();
$sql = 'SELECT nid FROM {node} WHERE uid = :uid AND type = venue';
$result = db_query($sql, array(':uid' => $user->uid));
foreach ($result as $row) {
$items[] = $row->nid;
}
dsm($items);
然而,当我想选择内容类型"场地"来自"类型"在同一个数据库表中的列,我使用以下内容得到错误...
{{1}}
DOException:SQLSTATE [42S22]:找不到列:1054未知列 '场地' in' where子句&#39 ;:SELECT nid FROM {node} WHERE uid =:uid AND type =场地;数组([:uid] => 1)
我在这里不明白的事情。该列被称为"键入",我不是要求它查找名为""我是吗?
答案 0 :(得分:4)
将列与字符串进行比较时,需要用引号包装字符串,如果不这样,优化器会将其视为列(除非是数字)。试试这个:
$sql = "SELECT nid FROM {node} WHERE uid = :uid AND type = 'venue'"