本文整理汇总了PHP中getChildCategories函数的典型用法代码示例。如果您正苦于以下问题:PHP getChildCategories函数的具体用法?PHP getChildCategories怎么用?PHP getChildCategories使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getChildCategories函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChildCategories
function getChildCategories($db, $parent = 0, $indent = "")
{
$result = '';
$sql = 'SELECT * FROM category WHERE parent=' . $parent;
$res = $db->query($sql);
while ($row = $res->fetch(SQLITE_ASSOC)) {
$result .= $row['id'] . ':' . $indent . $row['title'] . "\n";
$result .= getChildCategories($db, $row['id'], $indent . '...');
}
return $result;
}
示例2: getChildCategories
/**
* gets the child categories of a category
*/
function getChildCategories($category)
{
$id = $category["idCategory"];
$target = "category/parent_id/" . $id;
logger($target);
$path = $category["path"];
$client = Mage::getModel('codex_api/api');
if (null !== ($response = $client->call($target, 'GET'))) {
foreach ($response as $key => $category) {
$category["path"] = $path . "/" . $id;
writeCategory($category);
getChildCategories($category);
}
}
}
示例3: catchup_feed
function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all')
{
if (!$owner_uid) {
$owner_uid = $_SESSION['uid'];
}
//if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
// Todo: all this interval stuff needs some generic generator function
$date_qpart = "false";
switch ($mode) {
case "1day":
if (DB_TYPE == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
}
break;
case "1week":
if (DB_TYPE == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
}
break;
case "2week":
if (DB_TYPE == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
}
break;
default:
$date_qpart = "true";
}
if (is_numeric($feed)) {
if ($cat_view) {
if ($feed >= 0) {
if ($feed > 0) {
$children = getChildCategories($feed, $owner_uid);
array_push($children, $feed);
$children = join(",", $children);
$cat_qpart = "cat_id IN ({$children})";
} else {
$cat_qpart = "cat_id IS NULL";
}
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND feed_id IN\n\t\t\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_feeds WHERE {$cat_qpart}) AND {$date_qpart}) as tmp)");
} else {
if ($feed == -2) {
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)\n\t\t\t\t\t\t\t\tFROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND {$date_qpart}) > 0\n\t\t\t\t\t\t\t\tAND unread = true AND owner_uid = {$owner_uid}");
}
}
} else {
if ($feed > 0) {
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND feed_id = {$feed} AND {$date_qpart}) as tmp)");
} else {
if ($feed < 0 && $feed > LABEL_BASE_INDEX) {
// special, like starred
if ($feed == -1) {
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND marked = true AND {$date_qpart}) as tmp)");
}
if ($feed == -2) {
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND published = true AND {$date_qpart}) as tmp)");
}
if ($feed == -3) {
$intl = get_pref("FRESH_ARTICLE_MAX_AGE");
if (DB_TYPE == "pgsql") {
$match_part = "date_entered > NOW() - INTERVAL '{$intl} hour' ";
} else {
$match_part = "date_entered > DATE_SUB(NOW(),\n\t\t\t\t\t\t\t\tINTERVAL {$intl} HOUR) ";
}
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND score >= 0 AND unread = true AND {$date_qpart} AND {$match_part}) as tmp)");
}
if ($feed == -4) {
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t\t(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id\n\t\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND {$date_qpart}) as tmp)");
}
} else {
if ($feed < LABEL_BASE_INDEX) {
// label
$label_id = feed_to_label_id($feed);
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t\t(SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id\n\t\t\t\t\t\t\t\t\tAND label_id = '{$label_id}' AND ref_id = article_id\n\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid} AND unread = true AND {$date_qpart}) as tmp)");
}
}
}
}
ccache_update($feed, $owner_uid, $cat_view);
} else {
// tag
db_query("UPDATE ttrss_user_entries\n\t\t\t\t\tSET unread = false, last_read = NOW() WHERE ref_id IN\n\t\t\t\t\t\t(SELECT id FROM\n\t\t\t\t\t\t\t(SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id\n\t\t\t\t\t\t\t\tAND post_int_id = int_id AND tag_name = '{$feed}'\n\t\t\t\t\t\t\t\tAND ttrss_user_entries.owner_uid = {$owner_uid} AND unread = true AND {$date_qpart}) as tmp)");
}
}
示例4: filter_to_sql
function filter_to_sql($link, $filter, $owner_uid)
{
$query = array();
if (DB_TYPE == "pgsql") {
$reg_qpart = "~";
} else {
$reg_qpart = "REGEXP";
}
foreach ($filter["rules"] as $rule) {
$regexp_valid = preg_match('/' . $rule['reg_exp'] . '/', $rule['reg_exp']) !== FALSE;
if ($regexp_valid) {
$rule['reg_exp'] = db_escape_string($rule['reg_exp']);
switch ($rule["type"]) {
case "title":
$qpart = "LOWER(ttrss_entries.title) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
case "content":
$qpart = "LOWER(ttrss_entries.content) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
case "both":
$qpart = "LOWER(ttrss_entries.title) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "') OR LOWER(" . "ttrss_entries.content) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
case "tag":
$qpart = "LOWER(ttrss_user_entries.tag_cache) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
case "link":
$qpart = "LOWER(ttrss_entries.link) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
case "author":
$qpart = "LOWER(ttrss_entries.author) {$reg_qpart} LOWER('" . $rule['reg_exp'] . "')";
break;
}
if (isset($rule["feed_id"]) && $rule["feed_id"] > 0) {
$qpart .= " AND feed_id = " . db_escape_string($rule["feed_id"]);
}
if (isset($rule["cat_id"])) {
if ($rule["cat_id"] > 0) {
$children = getChildCategories($link, $rule["cat_id"], $owner_uid);
array_push($children, $rule["cat_id"]);
$children = join(",", $children);
$cat_qpart = "cat_id IN ({$children})";
} else {
$cat_qpart = "cat_id IS NULL";
}
$qpart .= " AND {$cat_qpart}";
}
array_push($query, "({$qpart})");
}
}
if (count($query) > 0) {
return "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
} else {
return "(false)";
}
}
示例5: getChildCategories
function getChildCategories($categories, $id, $recursive = true)
{
if ($categories == NULL) {
$categories = fetchCategories();
}
$n = count($categories);
$child = array();
for ($i = 0; $i < $n; $i++) {
$catId = $categories[$i]['cat_id'];
$parentId = $categories[$i]['cat_parent_id'];
if ($parentId == $id) {
$child[] = $catId;
if ($recursive) {
$child = array_merge($child, getChildCategories($categories, $catId));
}
}
}
return $child;
}
示例6: getChildCategories
<!-- Page Banner -->
<!-- shop-page -->
<div class="col-md-3 shop-sidebar">
<div class="sidebar-widgets">
<div class="shop-widget"> <h4 class="rad_h4">Categories</h4> <?php
echo ' <ul class="category-shop-list">';
getChildCategories('product_categories');
echo "</ul>";
?>
</div>
</div></div>
<!--</div>
<div class="col-md-3 shop-sidebar">
<div class="sidebar-widgets">
<div class="shop-widget">
<h4>Categories</h4>
<ul class="category-shop-list">
<li>
<a class="accordion-link" href="#">Watches <span>(4)</span></a>
<ul class="accordion-list-content">
<li><a href="#">Jackets <span>(7)</span></a></li>
<li><a href="#">Electronics <span>(10)</span></a></li>
示例7: array_merge
<?php
if (!defined('WEB_ROOT')) {
exit;
}
$productsPerRow = 2;
$productsPerPage = 4;
//$productList = getProductList($catId);
$children = array_merge(array($catId), getChildCategories(NULL, $catId));
$children = ' (' . implode(', ', $children) . ')';
$sql = "SELECT pd_id, pd_name, pd_price, pd_thumbnail, pd_qty, c.cat_id\r\n\t\tFROM tbl_product pd, tbl_category c\r\n\t\tWHERE pd.cat_id = c.cat_id AND pd.cat_id IN {$children} \r\n\t\tORDER BY pd_name";
$result = dbQuery(getPagingQuery($sql, $productsPerPage));
$pagingLink = getPagingLink($sql, $productsPerPage, "c={$catId}");
$numProduct = dbNumRows($result);
// the product images are arranged in a table. to make sure
// each image gets equal space set the cell width here
$columnWidth = (int) (100 / $productsPerRow);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="20">
<?php
if ($numProduct > 0) {
$i = 0;
while ($row = dbFetchAssoc($result)) {
extract($row);
if ($pd_thumbnail) {
$pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
} else {
$pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
}
if ($i % $productsPerRow == 0) {
echo '<tr>';
示例8: queryFeedHeadlines
//.........这里部分代码省略.........
// override query strategy and enable feed display when searching globally
if ($search && $search_mode == "all_feeds") {
$query_strategy_part = "ttrss_entries.id > 0";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
/* tags */
} else {
if (!is_numeric($feed)) {
$query_strategy_part = "ttrss_entries.id > 0";
$vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE\n\t\t\t\t\tid = feed_id) as feed_title,";
} else {
if ($feed > 0 && $search && $search_mode == "this_cat") {
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
$tmp_result = false;
if ($cat_view) {
$tmp_result = db_query($link, "SELECT id\n\t\t\t\t\t\tFROM ttrss_feeds WHERE cat_id = '{$feed}'");
} else {
$tmp_result = db_query($link, "SELECT id\n\t\t\t\t\t\tFROM ttrss_feeds WHERE cat_id = (SELECT cat_id FROM ttrss_feeds\n\t\t\t\t\t\t\tWHERE id = '{$feed}') AND id != '{$feed}'");
}
$cat_siblings = array();
if (db_num_rows($tmp_result) > 0) {
while ($p = db_fetch_assoc($tmp_result)) {
array_push($cat_siblings, "feed_id = " . $p["id"]);
}
$query_strategy_part = sprintf("(feed_id = %d OR %s)", $feed, implode(" OR ", $cat_siblings));
} else {
$query_strategy_part = "ttrss_entries.id > 0";
}
} else {
if ($feed > 0) {
if ($cat_view) {
if ($feed > 0) {
if ($include_children) {
# sub-cats
$subcats = getChildCategories($link, $feed, $owner_uid);
if (count($subcats) == 0) {
$query_strategy_part = "cat_id = '{$feed}'";
} else {
array_push($subcats, $feed);
$query_strategy_part = "cat_id IN (" . implode(",", $subcats) . ")";
}
} else {
$query_strategy_part = "cat_id = '{$feed}'";
}
} else {
$query_strategy_part = "cat_id IS NULL";
}
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else {
$query_strategy_part = "feed_id = '{$feed}'";
}
} else {
if ($feed == 0 && !$cat_view) {
// archive virtual feed
$query_strategy_part = "feed_id IS NULL";
} else {
if ($feed == 0 && $cat_view) {
// uncategorized
$query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else {
if ($feed == -1) {
// starred virtual feed
$query_strategy_part = "marked = true";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else {
if ($feed == -2) {