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


PHP db_get_hash_array函数代码示例

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


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

示例1: 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

示例2: fn_add_bean_bag_filling_apply_option_modifiers_post

function fn_add_bean_bag_filling_apply_option_modifiers_post($product_options, &$base_value, $type, $orig_options, $orig_value, $fields, $extra)
{
    if (AREA == 'A') {
        return;
        //var_dump($_REQUEST); die();
        //var_dump($product_options, $base_value, $type, $orig_options, $orig_value, $fields, $extra); die();
        if (!empty($product_options) && $type == 'P') {
            $opt = array_pop($product_options);
            if ($opt == "346") {
                $bean_bag_150 = Registry::get('addons.add_bean_bag_filling.bean_bag_filling_150');
                $bean_bag_300 = Registry::get('addons.add_bean_bag_filling.bean_bag_filling_300');
                $exist_bean_bag_150 = db_get_field("SELECT product_id FROM ?:products WHERE product_id = ?i", $bean_bag_150);
                $exist_bean_bag_300 = db_get_field("SELECT product_id FROM ?:products WHERE product_id = ?i", $bean_bag_300);
                $p_prices = db_get_hash_array("SELECT price, product_id FROM ?:product_prices WHERE product_id in (?n)", 'product_id', array($exist_bean_bag_150, $exist_bean_bag_300));
                $p_data = db_get_row("SELECT bean_bag_filling_150, bean_bag_filling_300, bean_bag_quantity_150, bean_bag_quantity_300 FROM ?:products WHERE product_id = ?i", $extra['product_data']['product_id']);
                $mod_ = 0;
                //fn_write_die($p_data);
                $price_ = 0;
                if (!empty($p_data['bean_bag_quantity_150']) && $p_data['bean_bag_filling_150'] == 'Y' && !empty($exist_bean_bag_150)) {
                    $mod_ += $p_data['bean_bag_quantity_150'] * $p_prices[$exist_bean_bag_150]['price'];
                    $price_ += $mod_;
                }
                if (!empty($p_data['bean_bag_quantity_300']) && $p_data['bean_bag_filling_300'] == 'Y' && !empty($exist_bean_bag_300)) {
                    $mod_ += $p_data['bean_bag_quantity_300'] * $p_prices[$exist_bean_bag_300]['price'];
                    $price_ += $mod_;
                }
            }
            $base_value += $price_;
        }
        return $base_value;
    }
    //var_dump($base_value); die();
}
开发者ID:ambient-lounge,项目名称:site,代码行数:33,代码来源:func.php

示例3: fn_get_reward_points

/**
 * Get product/category/global earned points list
 *
 * @param integer $object_id Object ID
 * @param string $object_type Object type (see constants in the config.php file)
 * @param array $usergroup_ids Array with usergroup IDs
 * @param integer $company_id Company ID
 * @return array
 */
function fn_get_reward_points($object_id, $object_type = PRODUCT_REWARD_POINTS, $usergroup_ids = array(), $company_id = 0)
{
    $op_suffix = Registry::get('addons.reward_points.consider_zero_values') == 'Y' ? '=' : '';
    if (fn_allowed_for('ULTIMATE')) {
        if ($object_type == GLOBAL_REWARD_POINTS) {
            if (empty($company_id) && Registry::get('runtime.company_id')) {
                $company_id = Registry::get('runtime.company_id');
            } elseif (!Registry::get('runtime.company_id')) {
                return array();
            }
        }
    }
    if (!empty($usergroup_ids)) {
        if (Registry::get('addons.reward_points.several_points_action') == 'minimal_absolute') {
            $order_by = 'amount_type ASC, amount ASC';
        } elseif (Registry::get('addons.reward_points.several_points_action') == 'minimal_percentage') {
            $order_by = 'amount_type DESC, amount ASC';
        } elseif (Registry::get('addons.reward_points.several_points_action') == 'maximal_absolute') {
            $order_by = 'amount_type ASC, amount DESC';
        } elseif (Registry::get('addons.reward_points.several_points_action') == 'maximal_percentage') {
            $order_by = 'amount_type DESC, amount DESC';
        }
        return db_get_row("SELECT *, amount AS pure_amount FROM ?:reward_points" . " WHERE object_id = ?i AND object_type = ?s AND company_id = ?i" . " AND amount >{$op_suffix} 0 AND usergroup_id IN(?n)" . " ORDER BY ?p LIMIT 1", $object_id, $object_type, $company_id, $usergroup_ids, $order_by);
    } else {
        return db_get_hash_array("SELECT *, amount AS pure_amount FROM ?:reward_points" . " WHERE object_id = ?i AND object_type = ?s AND company_id = ?i AND amount >{$op_suffix} 0" . " ORDER BY usergroup_id", 'usergroup_id', $object_id, $object_type, $company_id);
    }
}
开发者ID:ambient-lounge,项目名称:site,代码行数:36,代码来源:func.php

示例4: 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

示例5: fn_get_banners

function fn_get_banners($params = array(), $lang_code = CART_LANGUAGE)
{
    $default_params = array('items_per_page' => 0);
    $params = array_merge($default_params, $params);
    $sortings = array('position' => '?:banners.position', 'timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
    $condition = $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    }
    $sorting = db_sort($params, $sortings, 'name', 'asc');
    $condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
    $condition .= fn_get_localizations_condition('?:banners.localization');
    $condition .= AREA == 'A' ? '' : " AND (?:banners.type != 'G' OR ?:banner_images.banner_image_id IS NOT NULL) ";
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    fn_set_hook('get_banners', $params, $condition, $sorting, $limit, $lang_code);
    $fields = array('?:banners.banner_id', '?:banners.type', '?:banners.target', '?:banners.status', '?:banners.position', '?:banner_descriptions.banner', '?:banner_descriptions.description', '?:banner_descriptions.url', '?:banner_images.banner_image_id');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:banners.company_id';
    }
    $banners = db_get_hash_array("SELECT ?p FROM ?:banners " . "LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s" . "LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id AND ?:banner_images.lang_code = ?s" . "WHERE 1 ?p ?p ?p", 'banner_id', implode(", ", $fields), $lang_code, $lang_code, $condition, $sorting, $limit);
    $banner_image_ids = fn_array_column($banners, 'banner_image_id');
    $images = fn_get_image_pairs($banner_image_ids, 'promo', 'M', true, false, $lang_code);
    foreach ($banners as $banner_id => $banner) {
        $banners[$banner_id]['main_pair'] = !empty($images[$banner['banner_image_id']]) ? reset($images[$banner['banner_image_id']]) : array();
    }
    fn_set_hook('get_banners_post', $banners, $params);
    return array($banners, $params);
}
开发者ID:ambient-lounge,项目名称:site,代码行数:34,代码来源:func.php

示例6: 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

示例7: fn_get_reward_points

function fn_get_reward_points($object_id, $object_type = PRODUCT_REWARD_POINTS, $usergroup_ids = array())
{
    $op_suffix = Registry::get('addons.reward_points.consider_zero_values') == 'Y' ? '=' : '';
    if (!empty($usergroup_ids)) {
        $order_by = 'amount_type ' . (POINTS_FOR_USERGROUP_BY_AMOUNT_TYPE == 'A' ? 'ASC' : 'DESC') . ', amount ' . (Registry::get('addons.reward_points.several_points_action') == 'min' ? 'ASC' : 'DESC');
        return db_get_row("SELECT *, amount AS pure_amount FROM ?:reward_points WHERE object_id = ?i AND object_type = ?s AND amount >{$op_suffix} 0 AND usergroup_id IN(?n) ORDER BY ?p LIMIT 1", $object_id, $object_type, $usergroup_ids, $order_by);
    } else {
        return db_get_hash_array("SELECT *, amount AS pure_amount FROM ?:reward_points WHERE object_id = ?i AND object_type = ?s AND amount >{$op_suffix} 0 ORDER BY usergroup_id", 'usergroup_id', $object_id, $object_type);
    }
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:10,代码来源:func.php

示例8: getList

 /**
  * Gets layouts list
  *
  * @param $array input params
  * @return array layouts list
  */
 public function getList($params = array())
 {
     $condition = '';
     if (fn_allowed_for('ULTIMATE')) {
         $condition = $this->getCompanyCondition('?:bm_layouts.company_id');
     }
     if (!empty($params['theme_name'])) {
         $condition .= db_quote(" AND theme_name = ?s", $params['theme_name']);
     }
     return db_get_hash_array("SELECT * FROM ?:bm_layouts WHERE 1 ?p", 'layout_id', $condition);
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:17,代码来源:Layout.php

示例9: fn_exim_set_product_categories

 function fn_exim_set_product_categories($product_id, $link_type, $data, $category_delimiter, $lang_code = CART_LANGUAGE)
 {
     if (empty($data)) {
         return false;
     }
     $set_delimiter = ';';
     $paths = array();
     $updated_categories = array();
     // Check if array is provided
     if (strpos($data, $set_delimiter) !== false) {
         $paths = explode($set_delimiter, $data);
         array_walk($paths, 'fn_trim_helper');
     } else {
         $paths[] = $data;
     }
     if (!fn_is_empty($paths)) {
         $old_data = db_get_hash_array("SELECT * FROM ?:products_categories WHERE product_id= ?i", 'category_id', $product_id);
         foreach ($old_data as $k => $v) {
             if ($v['link_type'] == $link_type) {
                 $updated_categories[] = $k;
             }
         }
         db_query("DELETE FROM ?:products_categories WHERE product_id = ?i AND link_type = ?s", $product_id, $link_type);
     }
     foreach ($paths as $category) {
         $categories = strpos($category, $category_delimiter) !== false ? explode($category_delimiter, $category) : array($category);
         if (!empty($categories)) {
             $parent_id = '0';
             foreach ($categories as $cat) {
                 $category_id = db_get_field("SELECT ?:categories.category_id FROM ?:category_descriptions INNER JOIN ?:categories ON ?:categories.category_id = ?:category_descriptions.category_id WHERE ?:category_descriptions.category = ?s AND lang_code = ?s AND parent_id = ?i", $cat, $lang_code, $parent_id);
                 if (!empty($category_id)) {
                     $parent_id = $category_id;
                 } else {
                     $category_data = array('parent_id' => $parent_id, 'category' => $cat);
                     $category_id = fn_update_category($category_data);
                     $parent_id = $category_id;
                 }
             }
             $data = array('product_id' => $product_id, 'category_id' => $category_id, 'link_type' => $link_type);
             if (!empty($old_data) && !empty($old_data[$category_id])) {
                 $data = fn_array_merge($old_data[$category_id], $data);
             }
             db_query("REPLACE INTO ?:products_categories ?e", $data);
             $updated_categories[] = $category_id;
         }
     }
     if (!empty($updated_categories)) {
         fn_update_product_count($updated_categories);
         return true;
     }
     return false;
 }
开发者ID:diedsmiling,项目名称:busenika,代码行数:52,代码来源:products.php

示例10: fn_get_store_locations

function fn_get_store_locations($params, $items_per_page = 0, $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('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_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("?:store_location_descriptions.name LIKE ?l", "%{$piece}%");
            // check search words
            $tmp .= db_quote(" OR ?:store_location_descriptions.description LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:store_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('?:store_locations.localization') : '';
    $sorting = "?:store_locations.position, ?:store_location_descriptions.name";
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:store_locations.store_location_id) FROM ?:store_locations ?p WHERE ?p", $join, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $data = db_get_hash_array('SELECT ?p FROM ?:store_locations ?p WHERE ?p GROUP BY ?:store_locations.store_location_id ORDER BY ?p ?p', 'store_location_id', implode(', ', $fields), $join, $condition, $sorting, $limit);
    return array($data, $params);
}
开发者ID:askzap,项目名称:ask-zap,代码行数:48,代码来源:func.php

示例11: getList

 /**
  * Return list of product menus
  * @static
  * @param  string $condition SQL condition
  * @param  string $lang_code
  * @return array  List of product menus sorted by position by menu_id
  */
 public static function getList($condition = '', $lang_code = CART_LANGUAGE)
 {
     /**
      * Prepare params for sql query before get menus list
      * @param string $lang_code
      */
     fn_set_hook('get_menus_pre', $join, $condition, $lang_code);
     $menus = db_get_hash_array("SELECT * FROM ?:menus " . "LEFT JOIN ?:menus_descriptions " . "ON ?:menus.menu_id = ?:menus_descriptions.menu_id " . "?p " . "WHERE ?:menus_descriptions.lang_code = ?s ?p ?p", 'menu_id', $join, $lang_code, fn_get_company_condition('?:menus.company_id'), $condition);
     /**
      * Process menus list after sql query
      * @param array $menus Array of menus data
      * @param string $lang_code
      */
     fn_set_hook('get_menus_post', $menus, $lang_code);
     return $menus;
 }
开发者ID:askzap,项目名称:ultimate,代码行数:23,代码来源:Menu.php

示例12: fn_get_all_cities

function fn_get_all_cities($avail_only = true, $lang_code = CART_LANGUAGE)
{
    $avail_cond = $avail_only == true ? " WHERE a.status = 'A' AND b.status = 'A'" : '';
    //return db_get_hash_multi_array("SELECT a.country_code, a.code, b.state FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s $avail_cond ORDER BY a.country_code, b.state", array('country_code'), $lang_code);
    $countries = db_get_hash_multi_array("SELECT a.country_code, a.code as state_id, b.code, c.city, b.city_id FROM ?:states as a " . "LEFT JOIN ?:rus_cities as b ON b.state_id = a.state_id " . "LEFT JOIN ?:rus_city_descriptions as c ON c.city_id = b.city_id AND c.lang_code = ?s " . "{$avail_cond} ORDER BY a.country_code, b.code, c.city", array('country_code'), $lang_code);
    $rus_countries = db_get_hash_array("SELECT city_id, city FROM ?:rus_city_descriptions WHERE lang_code = ?s", 'city_id', 'ru');
    $cities = array();
    foreach ($countries as $c_code => $states) {
        foreach ($states as $city) {
            if (!empty($city['city_id'])) {
                $cities[$c_code][$city['state_id']][] = array('code' => $city['code'], 'city' => empty($city['city']) ? $rus_countries[$city['city_id']]['city'] : $city['city']);
            }
        }
    }
    return $cities;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:16,代码来源:func.php

示例13: getList

 /**
  * Gets list of containers
  *
  * @param  array $params input params
  * @return array Array of containers data as position => data
  */
 public static function getList($params = array())
 {
     $fields = array('c.*');
     $join = $condition = '';
     if (!empty($params['location_id'])) {
         $condition .= db_quote(" AND c.location_id = ?i", $params['location_id']);
     }
     if (!empty($params['container_id'])) {
         $condition .= db_quote(" AND c.container_id = ?i", $params['container_id']);
     }
     if (!empty($params['default_location'])) {
         $layout_id = db_get_field("SELECT layout_id FROM ?:bm_locations WHERE location_id = ?i", $params['default_location']);
         $join .= db_quote(" INNER JOIN ?:bm_locations as l ON c.location_id = l.location_id AND l.is_default = 1 AND l.layout_id = ?i", $layout_id);
         $condition .= db_quote(" AND c.position IN ('TOP_PANEL', 'HEADER', 'FOOTER')");
         $fields[] = db_quote('IF (c.location_id != ?i, 0, 1) as `default`', $params['default_location']);
     }
     $containers = db_get_hash_array("SELECT " . implode(', ', $fields) . " FROM ?:bm_containers as c ?p WHERE 1 ?p", 'position', $join, $condition);
     return $containers;
 }
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:25,代码来源:Container.php

示例14: getList

 /**
  * Return list of product tabs
  *
  * @param  string $condition  Query condition; it is treated as a WHERE clause
  * @param  int    $product_id Product identifier
  * @param  string $lang_code  2 letter language code
  * @return array  Array of product tabs sorted by position and tab_id
  */
 public function getList($condition = '', $product_id = 0, $lang_code = DESCR_SL)
 {
     $join = '';
     $fields = array('*');
     /**
      * Prepares params for SQL query before getting product tabs
      * @param array $fields array of table column names to be returned
      * @param string $condition Query condition; it is treated as a WHERE clause
      * @param string $lang_code 2 letter language code
      */
     fn_set_hook('get_product_tabs_pre', $fields, $join, $condition, $lang_code);
     $fields = array_merge($fields, array('?:product_tabs.status as status', '?:product_tabs.block_id as block_id', '?:product_tabs.company_id as company_id', '?:product_tabs_descriptions.name as name '));
     $tabs = db_get_hash_array("SELECT ?p FROM ?:product_tabs " . "LEFT JOIN ?:product_tabs_descriptions " . "ON ?:product_tabs.tab_id = ?:product_tabs_descriptions.tab_id " . "LEFT JOIN ?:bm_blocks " . "ON ?:bm_blocks.block_id = ?:product_tabs.block_id " . "?p " . "WHERE ?:product_tabs_descriptions.lang_code = ?s ?p ?p ORDER BY position", 'tab_id', implode(',', $fields), $join, $lang_code, $this->getCompanyCondition('?:product_tabs.company_id'), $condition);
     foreach ($tabs as $tab_id => $tab) {
         if (!empty($tab['addon'])) {
             $addons = Registry::get('addons');
             if ($addons[$tab['addon']]['status'] != 'A') {
                 unset($tabs[$tab_id]);
                 continue;
             }
         }
         $tabs[$tab_id]['items_ids'] = explode(',', $tab['product_ids']);
         $tabs[$tab_id]['items_count'] = count($tabs[$tab_id]['items_ids']);
         if ($product_id > 0) {
             if (array_search($product_id, $tabs[$tab_id]['items_ids']) !== false) {
                 if ($tab['status'] == 'A') {
                     $tabs[$tab_id]['status'] = 'D';
                 } else {
                     $tabs[$tab_id]['status'] = 'A';
                 }
             }
         }
     }
     /**
      * Processes product tabs list after getting it
      * @param array $tabs Array of product tabs data
      * @param string $lang_code 2 letter language code
      */
     fn_set_hook('get_product_tabs_post', $tabs, $lang_code);
     return $tabs;
 }
开发者ID:askzap,项目名称:ultimate,代码行数:49,代码来源:ProductTabs.php

示例15: fn_paypal_user_login

function fn_paypal_user_login($checkout_details)
{
    $s_firstname = $s_lastname = '';
    if (!empty($checkout_details['SHIPTONAME'])) {
        $name = explode(' ', $checkout_details['SHIPTONAME']);
        $s_firstname = $name[0];
        unset($name[0]);
        $s_lastname = !empty($name[1]) ? implode(' ', $name) : '';
    }
    $s_state = $checkout_details['SHIPTOSTATE'];
    $s_state_codes = db_get_hash_array("SELECT ?:states.code, lang_code FROM ?:states LEFT JOIN ?:state_descriptions ON ?:state_descriptions.state_id = ?:states.state_id WHERE ?:states.country_code = ?s AND ?:state_descriptions.state = ?s", 'lang_code', $checkout_details['SHIPTOCOUNTRYCODE'], $s_state);
    if (!empty($s_state_codes[CART_LANGUAGE])) {
        $s_state = $s_state_codes[CART_LANGUAGE]['code'];
    } elseif (!empty($s_state_codes)) {
        $s_state = array_pop($s_state_codes);
        $s_state = $s_state['code'];
    }
    $address = array('s_firstname' => $s_firstname, 's_lastname' => $s_lastname, 's_address' => $checkout_details['SHIPTOSTREET'], 's_address_2' => !empty($checkout_details['SHIPTOSTREET2']) ? $checkout_details['SHIPTOSTREET2'] : '', 's_city' => $checkout_details['SHIPTOCITY'], 's_state' => $s_state, 's_country' => $checkout_details['SHIPTOCOUNTRYCODE'], 's_zipcode' => $checkout_details['SHIPTOZIP']);
    $_SESSION['auth'] = empty($_SESSION['auth']) ? array() : $_SESSION['auth'];
    $auth =& $_SESSION['auth'];
    // Update profile info if customer is registered user
    if (!empty($auth['user_id']) && $auth['area'] == 'C') {
        foreach ($address as $k => $v) {
            $_SESSION['cart']['user_data'][$k] = $v;
        }
        $profile_id = !empty($_SESSION['cart']['profile_id']) ? $_SESSION['cart']['profile_id'] : db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_type='P'", $auth['user_id']);
        db_query('UPDATE ?:user_profiles SET ?u WHERE profile_id = ?i', $_SESSION['cart']['user_data'], $profile_id);
        // Or jyst update info in the cart
    } else {
        // fill customer info
        $_SESSION['cart']['user_data'] = array('firstname' => $checkout_details['FIRSTNAME'], 'lastname' => $checkout_details['LASTNAME'], 'email' => $checkout_details['EMAIL'], 'company' => '', 'phone' => '', 'fax' => '');
        foreach ($address as $k => $v) {
            $_SESSION['cart']['user_data'][$k] = $v;
            $_SESSION['cart']['user_data']['b_' . substr($k, 2)] = $v;
        }
    }
    return true;
}
开发者ID:askzap,项目名称:ultimate,代码行数:38,代码来源:paypal_express.functions.php


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