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; }
/** * 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); } } }
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)"); } }
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)"; } }
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; }
<!-- 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>
<?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>';
function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false) { if (!$owner_uid) { $owner_uid = $_SESSION["uid"]; } $ext_tables_part = ""; if ($search) { if (SPHINX_ENABLED) { $ids = join(",", @sphinx_search($search, 0, 500)); if ($ids) { $search_query_part = "ref_id IN ({$ids}) AND "; } else { $search_query_part = "ref_id = -1 AND "; } } else { $search_query_part = search_to_sql($link, $search, $match_on); $search_query_part .= " AND "; } } else { $search_query_part = ""; } if ($filter) { if (DB_TYPE == "pgsql") { $query_strategy_part .= " AND updated > NOW() - INTERVAL '14 days' "; } else { $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL 14 DAY) "; } $override_order = "updated DESC"; $filter_query_part = filter_to_sql($filter) . " AND"; } else { $filter_query_part = ""; } if ($since_id) { $since_id_part = "ttrss_entries.id > {$since_id} AND "; } else { $since_id_part = ""; } $view_query_part = ""; if ($view_mode == "adaptive" || $view_query_part == "noscores") { if ($search) { $view_query_part = " "; } else { if ($feed != -1) { $unread = getFeedUnread($link, $feed, $cat_view); if ($cat_view && $feed > 0 && $include_children) { $unread += getCategoryChildrenUnread($link, $feed); } if ($unread > 0) { $view_query_part = " unread = true AND "; } } } } if ($view_mode == "marked") { $view_query_part = " marked = true AND "; } if ($view_mode == "published") { $view_query_part = " published = true AND "; } if ($view_mode == "unread") { $view_query_part = " unread = true AND "; } if ($view_mode == "updated") { $view_query_part = " (last_read is null and unread = false) AND "; } if ($limit > 0) { $limit_query_part = "LIMIT " . $limit; } $vfeed_query_part = ""; // 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) { // published virtual feed OR labels category if (!$cat_view) { $query_strategy_part = "published = true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $ext_tables_part = ",ttrss_labels2,ttrss_user_labels2"; $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND\n\t\t\t\t\t\tttrss_user_labels2.article_id = ref_id"; } } else { if ($feed == -6) { // recently read $query_strategy_part = "unread = false AND last_read IS NOT NULL"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $override_order = "last_read DESC"; } else { if ($feed == -3) { // fresh virtual feed $query_strategy_part = "unread = true AND score >= 0"; $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid); if (DB_TYPE == "pgsql") { $query_strategy_part .= " AND updated > NOW() - INTERVAL '{$intl} hour' "; } else { $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL {$intl} HOUR) "; } $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { if ($feed == -4) { // all articles virtual feed $query_strategy_part = "true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { if ($feed <= -10) { // labels $label_id = -$feed - 11; $query_strategy_part = "label_id = '{$label_id}' AND\n\t\t\t\t\tttrss_labels2.id = ttrss_user_labels2.label_id AND\n\t\t\t\t\tttrss_user_labels2.article_id = ref_id"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $ext_tables_part = ",ttrss_labels2,ttrss_user_labels2"; } else { $query_strategy_part = "id > 0"; // dumb } } } } } } } } } } } } if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) { $date_sort_field = "updated"; } else { $date_sort_field = "date_entered"; } if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { $order_by = "{$date_sort_field}"; } else { $order_by = "{$date_sort_field} DESC"; } if ($view_mode != "noscores") { $order_by = "score DESC, {$order_by}"; } if ($override_order) { $order_by = $override_order; } $feed_title = ""; if ($search) { $feed_title = "Search results"; } else { if ($cat_view) { $feed_title = getCategoryTitle($link, $feed); } else { if (is_numeric($feed) && $feed > 0) { $result = db_query($link, "SELECT title,site_url,last_error\n\t\t\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}' AND owner_uid = {$owner_uid}"); $feed_title = db_fetch_result($result, 0, "title"); $feed_site_url = db_fetch_result($result, 0, "site_url"); $last_error = db_fetch_result($result, 0, "last_error"); } else { $feed_title = getFeedTitle($link, $feed); } } } $content_query_part = "content as content_preview,"; if (is_numeric($feed)) { if ($feed >= 0) { $feed_kind = "Feeds"; } else { $feed_kind = "Labels"; } if ($limit_query_part) { $offset_query_part = "OFFSET {$offset}"; } if ($vfeed_query_part && get_pref($link, 'VFEED_GROUP_BY_FEED', $owner_uid)) { if (!$override_order) { $order_by = "ttrss_feeds.title, {$order_by}"; } } if ($feed != "0") { $from_qpart = "ttrss_entries,ttrss_user_entries,ttrss_feeds{$ext_tables_part}"; $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND"; } else { $from_qpart = "ttrss_entries,ttrss_user_entries{$ext_tables_part}\n\t\t\t\t\t\tLEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; } $query = "SELECT DISTINCT\n\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\tguid,\n\t\t\t\t\t\tttrss_entries.id,ttrss_entries.title,\n\t\t\t\t\t\tupdated,\n\t\t\t\t\t\tlabel_cache,\n\t\t\t\t\t\ttag_cache,\n\t\t\t\t\t\talways_display_enclosures,\n\t\t\t\t\t\tsite_url,\n\t\t\t\t\t\tnote,\n\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\tcomments,\n\t\t\t\t\t\tint_id,\n\t\t\t\t\t\tunread,feed_id,marked,published,link,last_read,orig_feed_id,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms,\n\t\t\t\t\t\t{$vfeed_query_part}\n\t\t\t\t\t\t{$content_query_part}\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms,\n\t\t\t\t\t\tauthor,score\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$from_qpart}\n\t\t\t\t\tWHERE\n\t\t\t\t\t{$feed_check_qpart}\n\t\t\t\t\tttrss_user_entries.ref_id = ttrss_entries.id AND\n\t\t\t\t\tttrss_user_entries.owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t{$search_query_part}\n\t\t\t\t\t{$filter_query_part}\n\t\t\t\t\t{$view_query_part}\n\t\t\t\t\t{$since_id_part}\n\t\t\t\t\t{$query_strategy_part} ORDER BY {$order_by}\n\t\t\t\t\t{$limit_query_part} {$offset_query_part}"; if ($_REQUEST["debug"]) { print $query; } $result = db_query($link, $query); } else { // browsing by tag $select_qpart = "SELECT DISTINCT " . "date_entered," . "guid," . "note," . "ttrss_entries.id as id," . "title," . "updated," . "unread," . "feed_id," . "orig_feed_id," . "marked," . "num_comments, " . "comments, " . "tag_cache," . "label_cache," . "link," . "last_read," . SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," . $since_id_part . $vfeed_query_part . $content_query_part . SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms," . "score "; $feed_kind = "Tags"; $all_tags = explode(",", $feed); if ($search_mode == 'any') { $tag_sql = "tag_name in (" . implode(", ", array_map("db_quote", $all_tags)) . ")"; $from_qpart = " FROM ttrss_entries,ttrss_user_entries,ttrss_tags "; $where_qpart = " WHERE " . "ref_id = ttrss_entries.id AND " . "ttrss_user_entries.owner_uid = {$owner_uid} AND " . "post_int_id = int_id AND {$tag_sql} AND " . $view_query_part . $search_query_part . $query_strategy_part . " ORDER BY {$order_by} " . $limit_query_part; } else { $i = 1; $sub_selects = array(); $sub_ands = array(); foreach ($all_tags as $term) { array_push($sub_selects, "(SELECT post_int_id from ttrss_tags WHERE tag_name = " . db_quote($term) . " AND owner_uid = {$owner_uid}) as A{$i}"); $i++; } if ($i > 2) { $x = 1; $y = 2; do { array_push($sub_ands, "A{$x}.post_int_id = A{$y}.post_int_id"); $x++; $y++; } while ($y < $i); } array_push($sub_ands, "A1.post_int_id = ttrss_user_entries.int_id and ttrss_user_entries.owner_uid = {$owner_uid}"); array_push($sub_ands, "ttrss_user_entries.ref_id = ttrss_entries.id"); $from_qpart = " FROM " . implode(", ", $sub_selects) . ", ttrss_user_entries, ttrss_entries"; $where_qpart = " WHERE " . implode(" AND ", $sub_ands); } // error_log("TAG SQL: " . $tag_sql); // $tag_sql = "tag_name = '$feed'"; DEFAULT way // error_log("[". $select_qpart . "][" . $from_qpart . "][" .$where_qpart . "]"); $result = db_query($link, $select_qpart . $from_qpart . $where_qpart); } return array($result, $feed_title, $feed_site_url, $last_error); }