왜 비 객체의 속성을 얻으려고하는지 알기 위해 노력하고 있습니다. 나는 객체와 배열에 대해 완전히 숙련 된 사람은 아니지만 노력하고 있습니다. 여기에 코드와 오류 메시지가 있습니다. 이 문제를 해결하는 방법에 대한 아이디어가 있습니까?비 객체의 속성
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: models/sitemodel.php
Line Number: 208 and 215
function getSubMenuPages()
{
$this->db->select('site_menu_structures.id');
$this->db->from('site_menu_structures');
$this->db->where('site_menu_structures.short_name', 'mainnav');
$query = $this->db->get();
$menu_id = $query->row()->id;
$this->db->select('site_menu_structures_links.id, site_menu_structures_links.short_name, is_category');
$this->db->from('site_menu_structures_links');
$this->db->where('site_menu_structures_links.menu_structure_id', $menu_id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$linksArray = $query->result();
foreach ($linksArray as $key => $link)
{
if ($link->is_category == 'Yes')
{
$linksArray->{$key}->child_links;
$this->db->select('site_menu_structures_links_children.link_name');
$this->db->from('site_menu_structures_links_children');
$this->db->where('site_menu_structures_links_children.site_menu_structures_links_id', $link->id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$linksArray->{$key}->child_links = $query->result();
}
}
}
}
return $linksArray;
}
당신이 받고있는 정확한 오류 메시지를 게시 할 수 시도? –
$ this-> db-> get(); 항상 객체를 반환합니까? ADOdb의 경우, 쿼리가 실패하면 false를 반환합니다. 따라서 if 문이'if ($ query && Query-> num_rows()) {' –
과 같은 형태가되게 할 수 있습니다. 208 및 215 행에 플래그를 지정할 수 있습니까? 줄 번호 거 터가 없기 때문입니다. –