每当我尝试在 drupal 的功能模块中执行此 sql 查询时,我都无法获得结果,但是当我尝试在 MySQL 中执行此操作时,我可以查看结果。我的代码如下所示:
function _get_subject_sub_category() {
$options = array();
$sql = "SELECT father.Subject_Code, child.Subject_Category
FROM {subjects} as child
INNER JOIN {subjects} as father ON (child.Parent_Category = father.Subject_Code
AND child.Level =2 )";
$result = db_query($sql);
foreach ($result as $row) {
$options[$row->father.Subject_Code] = $row->child.Subject_Category;
}
return $options;
}
我遇到的错误在 $options[$row->father.Subject_Code] = $row->child.Subject_Category;` 行中。
任何帮助将不胜感激。