Доброе утро. Разбираюсь с вопросом генерации ЧПУ url в opencart, нашел подходящий код в сети и настроил. Но я не совсем понимаю одну его функцию, а именно rows. Что в конкретном случае она возвращает? Буду благодарен за пояснения.
public function getProductPath($product_id)
{
$category_id = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
if (isset($category_id->rows[0]['category_id']) && ($category_id->rows[0]['category_id'] != 0)) {
$parent_id = $this->db->query("SELECT parent_id FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$category_id->rows[0]['category_id'] . "'");
if (isset($parent_id->rows[0]['parent_id']) && ($parent_id->rows[0]['parent_id'] != 0)) {
$category = $parent_id->rows[0]['parent_id'] . "_" . $category_id->rows[0]['category_id'];
$path_id_2 = $this->db->query("SELECT parent_id FROM " . DB_PREFIX . "category WHERE category_id = '" . $parent_id->rows[0]['parent_id'] . "'");
if (isset($path_id_2->rows[0]['parent_id']) && ($path_id_2->rows[0]['parent_id'] != 0)) {
$category = $path_id_2->rows[0]['parent_id'] . "_" . $parent_id->rows[0]['parent_id'] . "_" . $category_id->rows[0]['category_id'];
$path_id_3 = $this->db->query("SELECT parent_id FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$path_id_2->rows[0]['parent_id'] . "'");
if (isset($path_id_3->rows[0]['parent_id']) && ($path_id_3->rows[0]['parent_id'] != 0)) {
$category = $path_id_3->rows[0]['parent_id'] . "_" . $path_id_2->rows[0]['parent_id'] . "_" . $parent_id->rows[0]['parent_id'] . "_" . $category_id->rows[0]['category_id'];
$path_id_4 = $this->db->query("SELECT parent_id FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$path_id_3->rows[0]['parent_id'] . "'");
if (isset($path_id_4->rows[0]['parent_id']) && ($path_id_4->rows[0]['parent_id'] != 0)) {
$category = $path_id_4->rows[0]['parent_id'] . "_" . $path_id_3->rows[0]['parent_id'] . "_" . $path_id_2->rows[0]['parent_id'] . "_" . $parent_id->rows[0]['parent_id'] . "_" . $category_id->rows[0]['category_id'];
}
}
}
} else {
$category = $category_id->rows[0]['category_id'];
}
} else {
$category = false;
}
return $category;
}