我有这个错误可以有人帮助我。
这是我的代码:
function getMenu($parentId = 0)
{
$sql = "select * from tbl_category where parent=?";
$result = $this->doSelect($sql, array($parentId));
foreach ($result as $row) {
$children = $this->getMenu($row['id']);
if (sizeof ($children) > 0) {
$row['children'] = $children;
}
@$data[] = $row;
}
return @$data;
}
这是我的错误
警告:sizeof():参数必须是数组或对象 在C:\ xampp \ htdocs \ digikalamvc \ core \ model.php中实现Countable 第302行
答案 0 :(得分:0)
请更新条件,例如我更新了以下代码。我希望它对你有所帮助。
function getMenu($parentId = 0)
{
$sql = "select * from tbl_category where parent=?";
$result = $this->doSelect($sql, array($parentId));
foreach ($result as $row) {
$children = $this->getMenu($row['id']);
if (!empty($children) && sizeof ($children) > 0) {
$row['children'] = $children;
}
@$data[] = $row;
}
return @$data;
}