【发布时间】:2020-04-18 21:48:18
【问题描述】:
我有一个 oc_category_description 表,其中列是:
- category_id
- 姓名
以及列所在的其他表 oc_category:
- category_id
- 图片
- parent_id
这里是 oc_category_description 表的示例图片
oc_category 表
这里我想显示名字、category_id、image、parent_id,其中oc_category parent_id 为0;
这里是sql:
php
function getMainCategory()
{
$stmt = $this->con->prepare("SELECT category_id, image, parent_id, (SELECT oc_category_description.name FROM oc_category_description WHERE oc_category.category_id = oc_category_description.category_id) FROM oc_category WHERE parent_id = 0 ORDER BY category_id ASC");
$stmt->execute();
$stmt->bind_result($category_id, $image, $parent_id, $name);
$users = array();
while ($stmt->fetch()) {
$temp = array();
$temp['category_id'] = $category_id;
$temp['image'] = $image;
$temp['parent_id'] = $parent_id;
$temp['name'] = $name;
array_push($users, $temp);
}
return $users;
}
但它什么也没返回:(
【问题讨论】:
-
这是a question you have asked previously 的完全相同的副本,由于某种原因已关闭。请考虑编辑该内容并使其更清晰,而不是发布新内容。
-
我编辑了上一个但没有得到任何解决方案。
-
但是发布重复的问题不是一个好主意。如果您的编辑没有帮助读者更好地理解问题,我想发布确切的问题也无济于事。