当前位置: 首页>>代码示例>>PHP>>正文


PHP db_paginate函数代码示例

本文整理汇总了PHP中db_paginate函数的典型用法代码示例。如果您正苦于以下问题:PHP db_paginate函数的具体用法?PHP db_paginate怎么用?PHP db_paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_paginate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_get_tags

function fn_get_tags($params = array(), $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('tags', $params);
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define sort fields
    $sortings = array('tag' => '?:tags.tag', 'status' => '?:tags.status', 'popularity' => 'popularity', 'users' => 'users');
    $conditions = fn_tags_build_conditions($params);
    $sorting = db_sort($params, $sortings, 'tag', 'asc');
    $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    } elseif (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:tags.tag_id)) FROM ?:tags LEFT JOIN ?:tag_links ON ?:tags.tag_id = ?:tag_links.tag_id WHERE 1 ?p", $conditions);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $tags = db_get_hash_array("SELECT ?:tags.tag_id, ?:tag_links.object_id, ?:tag_links.object_type, ?:tags.tag, ?:tags.status, COUNT(?:tag_links.tag_id) as popularity " . "FROM ?:tags LEFT JOIN ?:tag_links ON ?:tag_links.tag_id = ?:tags.tag_id WHERE 1 ?p GROUP BY ?:tags.tag_id {$sorting} {$limit}", 'tag_id', $conditions);
    if (!empty($params['count_objects'])) {
        $objs = db_get_array("SELECT tag_id, COUNT(DISTINCT(object_id)) as count, object_type " . "FROM ?:tag_links WHERE tag_id IN (?n) GROUP BY tag_id, object_type", array_keys($tags));
        foreach ($objs as $v) {
            $tags[$v['tag_id']]['objects_count'][$v['object_type']] = $v['count'];
        }
    }
    // Generate popularity level
    foreach ($tags as $k => $v) {
        $level = ceil(log($v['popularity']));
        $tags[$k]['level'] = $level > TAGS_MAX_LEVEL ? TAGS_MAX_LEVEL : $level;
    }
    if (!empty($params['sort_popular'])) {
        $tags = fn_sort_array_by_key($tags, 'tag', SORT_ASC);
    }
    return array($tags, $params);
}
开发者ID:askzap,项目名称:ultimate,代码行数:34,代码来源:func.php

示例2: fn_get_seo_rules

function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    $condition = fn_get_seo_company_condition('?:seo_names.company_id');
    $lang_code = fn_get_corrected_seo_lang_code($lang_code);
    $global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' ?p GROUP BY dispatch", $condition);
    $local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
    if ($diff = array_diff($global_total, $local_total)) {
        foreach ($diff as $disp) {
            fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, '', DESCR_SL);
        }
    }
    // Init filter
    $params = LastView::instance()->update('seo_rules', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
    }
    if (isset($params['rule_params']) && fn_string_not_empty($params['rule_params'])) {
        $condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['rule_params']) . "%");
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
    return array($seo_data, $params);
}
开发者ID:askzap,项目名称:ultimate,代码行数:30,代码来源:seo_rules.php

示例3: fn_get_seo_redirects

function fn_get_seo_redirects($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    // Init filter
    $params = LastView::instance()->update('seo_redirects', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $condition = '';
    if (isset($params['src']) && fn_string_not_empty($params['src'])) {
        $condition .= db_quote(" AND src LIKE ?l", "%" . trim($params['src']) . "%");
    }
    if (!empty($params['type'])) {
        $condition .= db_quote(" AND type = ?s", $params['type']);
    }
    if (!empty($params['lang_code'])) {
        $condition .= db_quote(" AND lang_code = ?s", $params['lang_code']);
    }
    $condition .= fn_get_seo_company_condition('?:seo_redirects.company_id');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_redirects WHERE 1 ?p", $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $seo_redirects = db_get_hash_array("SELECT * FROM ?:seo_redirects WHERE 1 ?p ORDER BY src {$limit}", 'redirect_id', $condition);
    if (!empty($seo_redirects)) {
        foreach ($seo_redirects as $key => $seo_redirect) {
            $seo_redirects[$key]['parsed_url'] = fn_generate_seo_url_from_schema($seo_redirect);
        }
    }
    return array($seo_redirects, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:31,代码来源:seo_redirects.php

示例4: getVariables

 public static function getVariables($params, $items_per_page = 0, $lang_code = DESCR_SL)
 {
     // Set default values to input params
     $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
     $params = array_merge($default_params, $params);
     $fields = array('lang.value' => true, 'lang.name' => true);
     if (!empty($params['fields'])) {
         $fields = array_merge($fields, $params['fields']);
     }
     $tables = array('?:language_values as lang');
     $left_join = array();
     $condition = array();
     $condition['param1'] = db_quote('lang.lang_code = ?s', $lang_code);
     if (isset($params['q']) && fn_string_not_empty($params['q'])) {
         $condition['param2'] = db_quote('(lang.name LIKE ?l OR lang.value LIKE ?l)', '%' . trim($params['q']) . '%', '%' . trim($params['q']) . '%');
     }
     fn_set_hook('get_language_variable', $fields, $tables, $left_join, $condition, $params);
     $joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
     $limit = '';
     if (!empty($params['items_per_page'])) {
         $params['total_items'] = db_get_field('SELECT COUNT(*) FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition));
         $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
     }
     $lang_data = db_get_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition) . ' ORDER BY lang.name ' . $limit);
     return array($lang_data, $params);
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:26,代码来源:Values.php

示例5: fn_get_promotions

/**
 * Get promotions
 *
 * @param array $params array with search params
 * @param int $items_per_page
 * @param string $lang_code
 * @return array list of promotions in first element, filtered parameters in second
 */
function fn_get_promotions($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('promotions', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page, 'get_hidden' => true);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array("?:promotions.*", "?:promotion_descriptions.name", "?:promotion_descriptions.detailed_description", "?:promotion_descriptions.short_description");
    // Define sort fields
    $sortings = array('name' => "?:promotion_descriptions.name", 'priority' => "?:promotions.priority", 'zone' => "?:promotions.zone", 'status' => "?:promotions.status");
    $condition = $join = $group = '';
    $condition .= fn_get_company_condition('?:promotions.company_id');
    $statuses = array('A');
    if (!empty($params['get_hidden'])) {
        $statuses[] = 'H';
    }
    if (!empty($params['promotion_id'])) {
        $condition .= db_quote(' AND ?:promotions.promotion_id IN (?n)', $params['promotion_id']);
    }
    if (!empty($params['active'])) {
        $condition .= db_quote(" AND IF(from_date, from_date <= ?i, 1) AND IF(to_date, to_date >= ?i, 1) AND status IN (?a)", TIME, TIME, $statuses);
    }
    if (fn_allowed_for('ULTIMATE:FREE')) {
        $params['zone'] = 'catalog';
    }
    if (!empty($params['zone'])) {
        $condition .= db_quote(" AND ?:promotions.zone = ?s", $params['zone']);
    }
    if (!empty($params['coupon_code'])) {
        $condition .= db_quote(" AND (CONCAT(LOWER(?:promotions.conditions_hash), ';') LIKE ?l OR CONCAT(LOWER(?:promotions.conditions_hash), ';') LIKE ?l)", "%coupon_code={$params['coupon_code']};%", "%auto_coupons={$params['coupon_code']};%");
    }
    if (!empty($params['coupons'])) {
        $condition .= db_quote(" AND ?:promotions.conditions_hash LIKE ?l", "%coupon_code=%");
    }
    if (!empty($params['auto_coupons'])) {
        $condition .= db_quote(" AND ?:promotions.conditions_hash LIKE ?l", "%auto_coupons=%");
    }
    $join .= db_quote(" LEFT JOIN ?:promotion_descriptions ON ?:promotion_descriptions.promotion_id = ?:promotions.promotion_id AND ?:promotion_descriptions.lang_code = ?s", $lang_code);
    fn_set_hook('get_promotions', $params, $fields, $sortings, $condition, $join);
    $sorting = db_sort($params, $sortings, 'name', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:promotions {$join} WHERE 1 {$condition} {$group}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    if (!empty($params['simple'])) {
        return db_get_hash_single_array("SELECT ?:promotions.promotion_id, ?:promotion_descriptions.name FROM ?:promotions {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}", array('promotion_id', 'name'));
    } else {
        $promotions = db_get_hash_array('SELECT ' . implode(', ', $fields) . " FROM ?:promotions {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}", 'promotion_id');
    }
    if (!empty($params['expand'])) {
        foreach ($promotions as $k => $v) {
            $promotions[$k]['conditions'] = !empty($v['conditions']) ? unserialize($v['conditions']) : array();
            $promotions[$k]['bonuses'] = !empty($v['bonuses']) ? unserialize($v['bonuses']) : array();
        }
    }
    return array($promotions, $params);
}
开发者ID:askzap,项目名称:ultimate,代码行数:67,代码来源:fn.promotions.php

示例6: fn_get_restricted_locations

function fn_get_restricted_locations($params, $items_per_page, $lang_code = CART_LANGUAGE)
{
    $default_params = array('page' => 1, 'q' => '', 'match' => 'any', 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('?:restricted_locations.*', '?:restricted_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:restricted_location_descriptions ON ?:restricted_locations.restricted_location_id = ?:restricted_location_descriptions.restricted_location_id AND ?:restricted_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:restricted_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code);
    $condition = 1;
    if (AREA == 'C') {
        $condition .= " AND status = 'A'";
    }
    // Search string condition for SQL query
    if (!empty($params['q'])) {
        if ($params['match'] == 'any') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            $tmp = db_quote("?:restricted_location_descriptions.name LIKE ?l", "%{$piece}%");
            // check search words
            $tmp .= db_quote(" OR ?:restricted_location_descriptions.description LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:restricted_location_descriptions.city LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:country_descriptions.country LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . $tmp . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
        unset($_condition);
    }
    $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:restricted_locations.localization') : '';
    $sorting = "?:restricted_location_descriptions.name";
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:restricted_locations.restricted_location_id) FROM ?:restricted_locations ?p WHERE ?p", $join, $condition);
        //Get total item count
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
        //Generate SQL condition to get only the necessary items
    }
    $data = db_get_array('SELECT ?p FROM ?:restricted_locations ?p WHERE ?p GROUP BY ?:restricted_locations.restricted_location_id ORDER BY ?p ?p', implode(', ', $fields), $join, $condition, $sorting, $limit);
    return array($data, $params);
}
开发者ID:ambient-lounge,项目名称:site,代码行数:50,代码来源:func.php

示例7: fn_gift_registry_get_userlog

function fn_gift_registry_get_userlog($params, $items_per_page = 0)
{
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $sortings = array('timestamp' => 'timestamp', 'amount' => 'amount');
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:reward_point_changes WHERE user_id = ?i", $params['user_id']);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $userlog = db_get_array("SELECT change_id, action, timestamp, amount, reason FROM ?:reward_point_changes WHERE user_id = ?i {$sorting} {$limit}", $params['user_id']);
    return array($userlog, $params);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:15,代码来源:reward_points.post.php

示例8: prepare

 public function prepare()
 {
     $this->result = '';
     $table_name = $this->model->getTableName();
     $field = $this->model->getPrimaryField();
     if (!empty($this->params['items_per_page']) || !empty($this->params['get_count'])) {
         if (empty($this->params['page'])) {
             $this->params['page'] = 1;
         }
         $this->params['total_items'] = db_get_field("SELECT COUNT(DISTINCT({$table_name}.{$field}))" . " FROM {$table_name}" . $this->joins->get() . $this->condition->get());
         if (!empty($this->params['items_per_page'])) {
             $this->result = db_paginate($this->params['page'], $this->params['items_per_page']);
         }
     }
     if (!empty($this->params['limit'])) {
         $this->result = db_quote(' LIMIT 0, ?i', $this->params['limit']);
     }
 }
开发者ID:vsguts,项目名称:cscart_models,代码行数:18,代码来源:Limit.php

示例9: fn_get_feedbacks

function fn_get_feedbacks($params, $items_per_page, $lang_code = CART_LANGUAGE)
{
    $params = LastView::instance()->update('feedbacks', $params);
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array("?:orders_feedback.feedback_id", "?:orders_feedback.statuses", "?:orders_feedback.subject", "?:orders_feedback.remind_in", "?:orders_feedback.status", "?:orders_feedback.lang_code");
    $sortings = array('feedback_id' => "?:orders_feedback.feedback_id", 'subject' => "?:orders_feedback.subject", 'statuses' => "?:orders_feedback.statuses", 'remind_in' => "?:orders_feedback.remind_in");
    $condition = $_condition = $join = $group = '';
    /*conditions*/
    $condition .= db_quote(' AND lang_code = ?s', $lang_code);
    /*conditions*/
    $sorting = db_sort($params, $sortings, 'feedback_id', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:orders_feedback.feedback_id) FROM ?:orders_feedback {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $feedbacks = db_get_array('SELECT ' . implode(', ', $fields) . " FROM ?:orders_feedback {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    LastView::instance()->processResults('feedbacks', $feedbacks, $params);
    return array($feedbacks, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:21,代码来源:func.php

示例10: fn_lv_get_product_default_navigation

/**
 * Gets products default navigation
 *
 * @param array $params Request params
 * @return array navigation data
 */
function fn_lv_get_product_default_navigation($params)
{
    if (empty($params['product_id'])) {
        return false;
    }
    $update_data = array();
    $product_id = $params['product_id'];
    if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
        $company_condition = fn_get_company_condition('c.company_id');
        $category_id = db_get_field("SELECT c.category_id, IF(pc.link_type = ?s, 1, 0) as is_main FROM ?:categories AS c LEFT JOIN ?:products_categories AS pc ON c.category_id = pc.category_id WHERE pc.product_id = ?i {$company_condition} ORDER BY is_main DESC", 'M', $product_id);
    } else {
        $category_id = db_get_field("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = ?s", $product_id, 'M');
    }
    if (empty($category_id)) {
        return false;
    }
    $search_params = array('cid' => $category_id, 'get_conditions' => true);
    list($fields, $join, $condition) = fn_get_products($search_params);
    $sorting = "ORDER BY descr1.product asc";
    // get product position in full list
    db_query("SET @r = 0;");
    $product_position = db_get_field("SELECT a.row FROM (SELECT products.product_id, @r := @r + 1 as row FROM ?:products as products {$join} WHERE 1 {$condition} GROUP BY products.product_id {$sorting}) AS a WHERE a.product_id = ?i", $product_id);
    $items_per_page = Registry::get('settings.Appearance.products_per_page');
    if (empty($product_position) || empty($items_per_page)) {
        return false;
    }
    $page = ceil($product_position / $items_per_page);
    $limit = db_paginate($page, $items_per_page);
    $stored_items_ids[$page] = db_get_fields("SELECT SQL_CALC_FOUND_ROWS products.product_id FROM ?:products as products {$join} WHERE 1 {$condition} GROUP BY products.product_id {$sorting} {$limit}");
    $total_items = db_get_found_rows();
    $total_pages = ceil($total_items / $items_per_page);
    unset($search_params['get_conditions']);
    $update_data['params'] = serialize($search_params);
    $update_data['view_results'] = array('items_ids' => $stored_items_ids, 'total_pages' => $total_pages, 'items_per_page' => $items_per_page, 'total_items' => $total_items);
    $update_data['view_results'] = serialize($update_data['view_results']);
    return $update_data;
}
开发者ID:askzap,项目名称:ultimate,代码行数:43,代码来源:frontend.functions.php

示例11: array

    if ($page_number == 1) {
        if (!empty($offers_features[$offer_key]['product_fields'])) {
            $product_objects = array();
            foreach ($offers_features[$offer_key]['product_fields'] as $product_field) {
                $product_objects[] = array('id' => 'product.' . $product_field, 'text' => __('yml2_product_field_' . $product_field));
            }
            $objects[] = array('id' => 'product_fields', 'text' => __('yml_export.product_fields'), 'children' => $product_objects);
        }
    }
    $statuses = array('A');
    $fields = db_quote("?:product_features.feature_id, ?:product_features_descriptions.description");
    $join = db_quote("LEFT JOIN ?:product_features_descriptions ON ?:product_features_descriptions.feature_id = ?:product_features.feature_id AND ?:product_features_descriptions.lang_code = ?s", $lang_code);
    $condition = db_quote("AND ?:product_features.status IN (?a) AND ?:product_features.feature_type != ?s", $statuses, ProductFeatures::GROUP);
    if (!empty($search_query)) {
        $condition .= db_quote(' AND ?:product_features_descriptions.description LIKE ?l', '%' . trim($search_query) . '%');
    }
    $total_items = 1;
    if (!empty($page_size)) {
        $total_items = db_get_field("SELECT COUNT(*) FROM ?:product_features {$join} WHERE 1 {$condition}");
        $limit = db_paginate($page_number, $page_size, $total_items);
    }
    $features = db_get_hash_array("SELECT {$fields} FROM ?:product_features {$join} WHERE 1 {$condition} ORDER BY ?:product_features.position {$limit}", 'feature_id');
    $feature_objects = array();
    foreach ($features as $feature) {
        $feature_objects[] = array('id' => 'feature.' . $feature['feature_id'], 'text' => $feature['description']);
    }
    $objects[] = array('id' => 'product_features', 'text' => __('yml_export.product_features'), 'children' => $feature_objects);
    Tygh::$app['ajax']->assign('objects', $objects);
    Tygh::$app['ajax']->assign('total_objects', $total_items);
    exit;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:yml.php

示例12: fn_get_rma_returns

function fn_get_rma_returns($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('rma', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname');
    // Define sort fields
    $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname");
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $join = $condition = $group = '';
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['rma_amount_from']) && fn_is_numeric($params['rma_amount_from'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount >= ?d", $params['rma_amount_from']);
    }
    if (isset($params['rma_amount_to']) && fn_is_numeric($params['rma_amount_to'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount <= ?d", $params['rma_amount_to']);
    }
    if (!empty($params['action'])) {
        $condition .= db_quote(" AND ?:rma_returns.action = ?s", $params['action']);
    }
    if (!empty($params['return_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.return_id = ?i", $params['return_id']);
    }
    if (!empty($params['request_status'])) {
        $condition .= db_quote(" AND ?:rma_returns.status IN (?a)", $params['request_status']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:rma_returns.timestamp >= ?i AND ?:rma_returns.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['order_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.order_id = ?i", $params['order_id']);
    }
    if (isset($params['user_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.user_id = ?i", $params['user_id']);
    }
    if (!empty($params['order_status'])) {
        $condition .= db_quote(" AND ?:orders.status IN (?a)", $params['order_status']);
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
        $group .= db_quote(" GROUP BY ?:rma_returns.return_id HAVING COUNT(?:orders.order_id) >= ?i", count($arr));
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT ?:rma_returns.return_id) FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON ?:rma_property_descriptions.property_id = ?:rma_returns.action LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $return_requests = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON (?:rma_property_descriptions.property_id = ?:rma_returns.action AND ?:rma_property_descriptions.lang_code = ?s) LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}", AREA == 'C' ? CART_LANGUAGE : DESCR_SL);
    LastView::instance()->processResults('rma_returns', $return_requests, $params);
    return array($return_requests, $params);
}
开发者ID:askzap,项目名称:ultimate,代码行数:76,代码来源:rma.post.php

示例13: fn_get_companies


//.........这里部分代码省略.........
 *		  <li>string zipcode - Zipcode of company</li>
 *		  <li>string country - 2-letters country code of company country</li>
 *		  <li>string state - State code of company</li>
 *		  <li>string city - City of company</li>
 *		  <li>string phone - Phone of company</li>
 *		  <li>string url - URL address of company</li>
 *		  <li>string fax - Fax number of company</li>
 *		  <li>mixed company_id - Company ID, array with company IDs or comma-separated list of company IDs.
 * If defined, data will be returned only for companies with such company IDs.</li>
 *		  <li>int exclude_company_id - Company ID, if defined,
 * result array will not include the data for company with such company ID.</li>
 *		  <li>int page - First page to displaying list of companies (if <i>$items_per_page</i> it not empty.</li>
 *		  <li>string sort_order - <i>ASC</i> or <i>DESC</i>: database query sorting order</li>
 *		  <li>string sort_by - One or list of database fields for sorting.</li>
 * </ul>
 * @param array $auth Array of user authentication data (e.g. uid, usergroup_ids, etc.)
 * @param int $items_per_page
 * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
 * @return array Array:
 * <ul>
 *		<li>0 - First element is array with companies data.</li>
 *		<li>1 - is possibly modified array with searh params (<i>$params</i>).</li>
 * </ul>
 */
function fn_get_companies($params, &$auth, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $_view = 'companies';
    $params = LastView::instance()->update($_view, $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:companies.company_id', '?:companies.lang_code', '?:companies.email', '?:companies.company', '?:companies.timestamp', '?:companies.status');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:companies.storefront';
        $fields[] = '?:companies.secure_storefront';
    }
    // Define sort fields
    $sortings = array('id' => '?:companies.company_id', 'company' => '?:companies.company', 'email' => '?:companies.email', 'date' => '?:companies.timestamp', 'status' => '?:companies.status');
    if (fn_allowed_for('ULTIMATE')) {
        $sortings['storefront'] = '?:companies.storefront';
    }
    $condition = $join = $group = '';
    $condition .= fn_get_company_condition('?:companies.company_id');
    $group .= " GROUP BY ?:companies.company_id";
    if (isset($params['company']) && fn_string_not_empty($params['company'])) {
        $condition .= db_quote(" AND ?:companies.company LIKE ?l", "%" . trim($params['company']) . "%");
    }
    if (!empty($params['status'])) {
        if (is_array($params['status'])) {
            $condition .= db_quote(" AND ?:companies.status IN (?a)", $params['status']);
        } else {
            $condition .= db_quote(" AND ?:companies.status = ?s", $params['status']);
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:companies.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['address']) && fn_string_not_empty($params['address'])) {
        $condition .= db_quote(" AND ?:companies.address LIKE ?l", "%" . trim($params['address']) . "%");
    }
    if (isset($params['zipcode']) && fn_string_not_empty($params['zipcode'])) {
        $condition .= db_quote(" AND ?:companies.zipcode LIKE ?l", "%" . trim($params['zipcode']) . "%");
    }
    if (!empty($params['country'])) {
        $condition .= db_quote(" AND ?:companies.country = ?s", $params['country']);
    }
    if (isset($params['state']) && fn_string_not_empty($params['state'])) {
        $condition .= db_quote(" AND ?:companies.state LIKE ?l", "%" . trim($params['state']) . "%");
    }
    if (isset($params['city']) && fn_string_not_empty($params['city'])) {
        $condition .= db_quote(" AND ?:companies.city LIKE ?l", "%" . trim($params['city']) . "%");
    }
    if (isset($params['phone']) && fn_string_not_empty($params['phone'])) {
        $condition .= db_quote(" AND ?:companies.phone LIKE ?l", "%" . trim($params['phone']) . "%");
    }
    if (isset($params['url']) && fn_string_not_empty($params['url'])) {
        $condition .= db_quote(" AND ?:companies.url LIKE ?l", "%" . trim($params['url']) . "%");
    }
    if (isset($params['fax']) && fn_string_not_empty($params['fax'])) {
        $condition .= db_quote(" AND ?:companies.fax LIKE ?l", "%" . trim($params['fax']) . "%");
    }
    if (!empty($params['company_id'])) {
        $condition .= db_quote(' AND ?:companies.company_id IN (?n)', $params['company_id']);
    }
    if (!empty($params['exclude_company_id'])) {
        $condition .= db_quote(' AND ?:companies.company_id != ?i', $params['exclude_company_id']);
    }
    fn_set_hook('get_companies', $params, $fields, $sortings, $condition, $join, $auth, $lang_code, $group);
    $sorting = db_sort($params, $sortings, 'company', 'asc');
    // Paginate search results
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:companies.company_id)) FROM ?:companies {$join} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $companies = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:companies {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    return array($companies, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:101,代码来源:fn.companies.php

示例14: fn_get_states

/**
 * Gets states list
 *
 * @param array $params search params
 * @param int $items_per_page number of states per page. Gets all if zero
 * @param string $lang_code language code
 * @return array 2 elements array, first - found states, second - filtered input params
 */
function fn_get_states($params = array(), $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('a.state_id', 'a.country_code', 'a.code', 'a.status', 'b.state', 'c.country');
    $condition = '1';
    if (!empty($params['only_avail'])) {
        $condition .= db_quote(" AND a.status = ?s", 'A');
    }
    if (!empty($params['q'])) {
        $condition .= db_quote(" AND b.state LIKE ?l", '%' . $params['q'] . '%');
    }
    if (!empty($params['country_code'])) {
        $condition .= db_quote(" AND a.country_code = ?s", $params['country_code']);
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT count(*) FROM ?:states as a WHERE ?p", $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $states = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:states as a " . "LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s " . "LEFT JOIN ?:country_descriptions as c ON c.code = a.country_code AND c.lang_code = ?s " . "WHERE ?p ORDER BY c.country, b.state {$limit}", $lang_code, $lang_code, $condition);
    return array($states, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:32,代码来源:fn.locations.php

示例15: fn_get_product_options_inventory

function fn_get_product_options_inventory($params, $items_per_page = 0, $lang_code = DESCR_SL)
{
    $default_params = array('page' => 1, 'product_id' => 0, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:product_options_inventory WHERE product_id = ?i", $params['product_id']);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $inventory = db_get_array("SELECT * FROM ?:product_options_inventory WHERE product_id = ?i ORDER BY position {$limit}", $params['product_id']);
    foreach ($inventory as $k => $v) {
        $inventory[$k]['combination'] = fn_get_product_options_by_combination($v['combination']);
        $inventory[$k]['image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'M', true, true, $lang_code);
        $inventory[$k]['additional_image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'A', true, true, $lang_code);
    }
    $product_options = fn_get_product_options($params['product_id'], $lang_code, true, true);
    $product_inventory = db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $params['product_id']);
    return array($inventory, $params, $product_options, $product_inventory);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:19,代码来源:product_options.php


注:本文中的db_paginate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。