本文整理汇总了PHP中categories::getCategoryParents方法的典型用法代码示例。如果您正苦于以下问题:PHP categories::getCategoryParents方法的具体用法?PHP categories::getCategoryParents怎么用?PHP categories::getCategoryParents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类categories
的用法示例。
在下文中一共展示了categories::getCategoryParents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
//.........这里部分代码省略.........
$error['attributes'] = $langArray['error_set_all_attributes'];
}
}
if (isset($error)) {
return $error;
}
$setQuery = '';
if ($fromAdmin) {
$setQuery .= " `price` = '" . sql_quote($_POST['price']) . "', ";
if (isset($_POST['free_file'])) {
$setQuery .= " `free_file` = 'true', ";
}
//周推荐至-时间
if (isset($_POST['weekly_to']) && trim($_POST['weekly_to']) != '') {
$setQuery .= " `weekly_to` = '" . sql_quote($_POST['weekly_to']) . "', ";
}
}
//演示地址
if (!isset($_POST['demo_url'])) {
$_POST['demo_url'] = '';
}
//作品状态是否为请求免费上架状态
if (!isset($_POST['free_request'])) {
$_POST['free_request'] = 'false';
}
//更新作品表
$mysql->query("\n\t\t\tUPDATE `items`\n\t\t\tSET `description` = '" . sql_quote($_POST['description']) . "',\n\t\t\t\t\t`free_request` = '" . sql_quote($_POST['free_request']) . "',\n\t\t\t\t\t{$setQuery}\n\t\t\t\t\t`demo_url` = '" . sql_quote($_POST['demo_url']) . "'\n\t\t\tWHERE `id` = '" . intval($id) . "'\n\t\t\tLIMIT 1\n\t\t");
require_once ROOT_PATH . '/apps/categories/models/categories.class.php';
$categoriesClass = new categories();
$allCategories = $categoriesClass->getAll();
$mysql->query("DELETE FROM `items_to_category` WHERE `item_id` = '" . intval($id) . "'");
if (is_array($_POST['category'])) {
foreach ($_POST['category'] as $category_id) {
$categories = $categoriesClass->getCategoryParents($allCategories, $category_id);
$categories = explode(',', $categories);
array_pop($categories);
$categories = array_reverse($categories);
$categories = ',' . implode(',', $categories) . ',';
$mysql->query("\n\t\t\t\t\tINSERT INTO `items_to_category` (\n\t\t\t\t\t\t`item_id`,\n\t\t\t\t\t\t`categories`\n\t\t\t\t\t) \n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t'" . intval($id) . "',\n\t\t\t\t\t\t'" . sql_quote($categories) . "'\n\t\t\t\t\t)\n\t\t\t\t");
}
} else {
$categories = $categoriesClass->getCategoryParents($allCategories, $_POST['category']);
$categories = explode(',', $categories);
array_pop($categories);
$categories = array_reverse($categories);
$categories = ',' . implode(',', $categories) . ',';
$mysql->query("\n\t\t\t\tINSERT INTO `items_to_category` (\n\t\t\t\t\t`item_id`,\n\t\t\t\t\t`categories`\n\t\t\t\t) \n\t\t\t\tVALUES (\n\t\t\t\t\t'" . intval($id) . "',\n\t\t\t\t\t'" . sql_quote($categories) . "'\n\t\t\t\t)\n\t\t\t");
}
//更新属性
$mysql->query("\n\t\t\tDELETE FROM `items_attributes`\n\t\t\tWHERE `item_id` = '" . intval($id) . "'\n\t\t");
$_POST['attributes'] = (array) (isset($_POST['attributes']) ? $_POST['attributes'] : array());
foreach ($_POST['attributes'] as $cID => $a) {
if (is_array($a)) {
foreach ($a as $ai) {
if (!trim($ai)) {
continue;
}
$mysql->query("\n\t\t\t\t\t\tINSERT INTO `items_attributes` (\n\t\t\t\t\t\t\t`item_id`,\n\t\t\t\t\t\t\t`attribute_id`,\n\t\t\t\t\t\t\t`category_id`\n\t\t\t\t\t\t)\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t'" . intval($id) . "',\n\t\t\t\t\t\t\t'" . sql_quote($ai) . "',\n\t\t\t\t\t\t\t'" . sql_quote($cID) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t");
}
} else {
if (!trim($a)) {
continue;
}
$mysql->query("\n\t\t\t\t\tINSERT INTO `items_attributes` (\n\t\t\t\t\t\t`item_id`,\n\t\t\t\t\t\t`attribute_id`,\n\t\t\t\t\t\t`category_id`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t'" . intval($id) . "',\n\t\t\t\t\t\t'" . sql_quote($a) . "',\n\t\t\t\t\t\t'" . sql_quote($cID) . "'\n\t\t\t\t\t)\n\t\t\t\t");
}
}
示例2: categories
<?php
//作品分类ajax接口
if (isset($_POST['categoryID'])) {
$categoryID = $_POST['categoryID'];
if (is_numeric($categoryID) || $categoryID == 'all') {
require_once '../../../config.php';
require_once $config['root_path'] . '/core/functions.php';
include_once $config['system_core'] . "/initEngine.php";
require_once ROOT_PATH . "/apps/categories/models/categories.class.php";
$categoriesClass = new categories();
if (is_numeric($categoryID)) {
$allCategories = $categoriesClass->getAll(0, 0, " `visible` = 'true' ");
$categoryParent = $categoriesClass->getCategoryParents($allCategories, $categoryID);
$categoryParent = explode(',', $categoryParent);
$categoryParent = array_reverse($categoryParent);
array_shift($categoryParent);
$whereQuery = " AND `id` IN (SELECT `item_id` FROM `items_to_category` WHERE `categories` LIKE '%," . intval($categoryID) . ",%') ";
} else {
$categoryParent = array('data' => '');
}
require_once ROOT_PATH . '/apps/items/models/items.class.php';
require_once ROOT_PATH . '/apps/users/models/users.class.php';
$itemsClass = new items();
$users = new users();
$order = '`datetime` DESC';
$items = $itemsClass->getAll(0, 40, " `status` = 'active' " . $whereQuery, $order);
$categories = $categoriesClass->getAll();
$res_data = array();
foreach ($items as $data) {
//用户信息