我有一個opencart商店,大約有1300個類別,我無法插入新類別或編輯現有類別。我已經安裝了分頁功能,但它只加快了分類視圖。我做了一些調試,發現一旦我點擊插入或編輯管理面板內,下面的函數進入無限循環。誰能幫我如何解決這一問題opencart getcategories函數進入無限循環
public function getCategories($parent_id = 0) {
$category_data = $this->cache->get('category.' . (int)$this->config->get('config_language_id') . '.' . (int)$parent_id);
if (!$category_data) {
$category_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY c.sort_order, cd.name ASC");
foreach ($query->rows as $result) {
$category_data[] = array(
'category_id' => $result['category_id'],
'name' => $this->getPath($result['category_id'], $this->config->get('config_language_id')),
'status' => $result['status'],
'sort_order' => $result['sort_order']
);
$category_data = array_merge($category_data, $this->getCategories($result['category_id']));
}
$this->cache->set('category.' . (int)$this->config->get('config_language_id') . '.' . (int)$parent_id, $category_data);
}
return $category_data;
}
在上面的哪一點開始循環?你能堅持一些回聲陳述,看看你有多遠? – Stuart
回聲沒有工作,因爲這dosen't克服...在array_merge,我成爲遞歸,它進入子類別...所以在我的服務器,它顯示500內部錯誤,並在我的本地服務器,它顯示超時..我也沒有達到緩存設置功能... – hablema
那麼你是說遞歸出現在'$ category_data = array_merge($ category_data,$ this-> getCategories($ result ['category_id']));'這是否正確?如果是這樣的話,在它回顯或var_dump之前,輸出$ category_data和$ result ['category_id']的值 – Stuart