本文整理汇总了PHP中db_get_hash_single_array函数的典型用法代码示例。如果您正苦于以下问题:PHP db_get_hash_single_array函数的具体用法?PHP db_get_hash_single_array怎么用?PHP db_get_hash_single_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_get_hash_single_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_projects_project_get_pages
function fn_projects_project_get_pages(&$pages, $params, $lang_code)
{
$projects_pages = array();
foreach ($pages as $idx => $page) {
if (!empty($page['page_type']) && $page['page_type'] == PAGE_TYPE_PROJECTS) {
$projects_pages[$idx] = $page['page_id'];
if (!empty($page['description'])) {
if (strpos($page['description'], PROJECTS_CUT) !== false) {
list($pages[$idx]['spoiler']) = explode(PROJECTS_CUT, $page['description'], 2);
} else {
$pages[$idx]['spoiler'] = $page['description'];
}
}
if (!empty($page['subpages'])) {
fn_projects_project_get_pages($pages[$idx]['subpages'], $params, $lang_code);
}
}
}
if (!empty($projects_pages)) {
$images = array();
$authors = db_get_hash_single_array("SELECT CONCAT(u.firstname, ' ', u.lastname) as author, b.page_id FROM ?:projects_authors as b LEFT JOIN ?:users as u ON b.user_id = u.user_id WHERE b.page_id IN (?n)", array('page_id', 'author'), $projects_pages);
if (!empty($params['get_image'])) {
$images = fn_get_image_pairs($projects_pages, 'projects', 'M', true, false, $lang_code);
}
foreach ($projects_pages as $idx => $page_id) {
$pages[$idx]['main_pair'] = !empty($images[$page_id]) ? reset($images[$page_id]) : array();
$pages[$idx]['author'] = !empty($authors[$page_id]) ? $authors[$page_id] : '';
}
}
}
示例2: fn_get_short_companies
/**
* Gets brief company data array: <i>(company_id => company_name)</i>
*
* @param array $params Array of search params:
* <ul>
* <li>string status - Status field from the <i>?:companies table</i></li>
* <li>string item_ids - Comma separated list of company IDs</li>
* <li>int displayed_vendors - Number of companies for displaying. Will be used as LIMIT condition</i>
* </ul>
* Global variable <i>$_REQUEST</i> can be passed as argument
* @return mixed If <i>$params</i> was not empty returns array:
* <ul>
* <li>companies - Hash array of companies <i>(company_id => company)</i></li>
* <li>count - Number of returned companies</li>
* </ul>
* else returns hash array of companies <i>(company_id => company)</i></li>
*/
function fn_get_short_companies($params = array())
{
$condition = $limit = $join = $companies = '';
if (!empty($params['status'])) {
$condition .= db_quote(" AND ?:companies.status = ?s ", $params['status']);
}
if (!empty($params['item_ids'])) {
$params['item_ids'] = fn_explode(",", $params['item_ids']);
$condition .= db_quote(" AND ?:companies.company_id IN (?n) ", $params['item_ids']);
}
if (!empty($params['displayed_vendors'])) {
$limit = 'LIMIT ' . $params['displayed_vendors'];
}
$condition .= Registry::get('runtime.company_id') ? fn_get_company_condition('?:companies.company_id', true, Registry::get('runtime.company_id')) : '';
fn_set_hook('get_short_companies', $params, $condition, $join, $limit);
$count = db_get_field("SELECT COUNT(*) FROM ?:companies {$join} WHERE 1 {$condition}");
$_companies = db_get_hash_single_array("SELECT ?:companies.company_id, ?:companies.company FROM ?:companies {$join} WHERE 1 {$condition} ORDER BY ?:companies.company {$limit}", array('company_id', 'company'));
if (!fn_allowed_for('ULTIMATE')) {
$companies[0] = Registry::get('settings.Company.company_name');
$companies = $companies + $_companies;
} else {
$companies = $_companies;
}
$return = array('companies' => $companies, 'count' => $count);
if (!empty($params)) {
unset($return['companies'][0]);
return array($return);
}
return $companies;
}
示例3: fn_exim_set_product_feature_categories
function fn_exim_set_product_feature_categories($feature_id, $feature_data, $lang_code)
{
static $categories_ids;
if (!empty($feature_data['parent_id'])) {
$categories_path = '';
$parent_feature = fn_get_product_feature_data($feature_data['parent_id']);
if (!empty($parent_feature['categories_path'])) {
$categories_path = $parent_feature['categories_path'];
}
} else {
if (!empty($feature_data['categories_path'])) {
$categories_path = array();
if (!isset($categories_ids)) {
$categories_ids = db_get_hash_single_array('SELECT category, category_id FROM ?:category_descriptions WHERE lang_code = ?s', array('category', 'category_id'), $lang_code);
}
$categories = explode(',', $feature_data['categories_path']);
if (!empty($categories)) {
foreach ($categories as $category) {
if (!empty($categories_ids[$category])) {
$categories_path[] = $categories_ids[$category];
}
}
}
$categories_path = implode(',', $categories_path);
} else {
$categories_path = '';
}
}
db_query("UPDATE ?:product_features SET categories_path = ?s WHERE feature_id = ?i", $categories_path, $feature_id);
if ($feature_data['feature_type'] == 'G') {
db_query("UPDATE ?:product_features SET categories_path = ?s WHERE parent_id = ?i", $categories_path, $feature_id);
}
return true;
}
示例4: fn_blog_post_get_pages
function fn_blog_post_get_pages(&$pages, $params, $lang_code)
{
$blog_pages = array();
foreach ($pages as $idx => $page) {
if (!empty($page['page_type']) && $page['page_type'] == PAGE_TYPE_BLOG) {
$blog_pages[$idx] = $page['page_id'];
if (!empty($page['description'])) {
if (strpos($page['description'], BLOG_CUT) !== false) {
list($pages[$idx]['spoiler']) = explode(BLOG_CUT, $page['description'], 2);
} else {
$pages[$idx]['spoiler'] = $page['description'];
}
}
if (!empty($params['get_image'])) {
$pages[$idx]['main_pair'] = fn_get_image_pairs($page['page_id'], 'blog', 'M', true, false, $lang_code);
}
if (!empty($page['subpages'])) {
fn_blog_post_get_pages($pages[$idx]['subpages'], $params, $lang_code);
}
}
}
if (!empty($blog_pages)) {
$authors = db_get_hash_single_array("SELECT CONCAT(u.firstname, ' ', u.lastname) as author, b.page_id FROM ?:blog_authors as b LEFT JOIN ?:users as u ON b.user_id = u.user_id WHERE b.page_id IN (?n)", array('page_id', 'author'), $blog_pages);
foreach ($blog_pages as $idx => $page_id) {
$pages[$idx]['author'] = $authors[$page_id];
}
}
}
示例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);
}
示例6: fn_get_image
function fn_get_image($image_id, $object_type, $lang_code = CART_LANGUAGE, $get_all_alts = false)
{
$path = $object_type;
if (!empty($image_id) && !empty($object_type)) {
$image_data = db_get_row("SELECT ?:images.image_id, ?:images.image_path, ?:common_descriptions.description as alt, ?:images.image_x, ?:images.image_y FROM ?:images LEFT JOIN ?:common_descriptions ON ?:common_descriptions.object_id = ?:images.image_id AND ?:common_descriptions.object_holder = 'images' AND ?:common_descriptions.lang_code = ?s WHERE ?:images.image_id = ?i", $lang_code, $image_id);
if ($get_all_alts && count(fn_get_translation_languages()) > 1) {
$image_data['alt'] = db_get_hash_single_array('SELECT description, lang_code FROM ?:common_descriptions WHERE object_id = ?i AND object_holder = ?s', array('lang_code', 'description'), $image_data['image_id'], 'images');
}
}
fn_attach_absolute_image_paths($image_data, $object_type);
return !empty($image_data) ? $image_data : false;
}
示例7: fn_get_ebay_sites
/**
* Get ebay sites
* @param array $site_ids
* @return array
*/
function fn_get_ebay_sites(array $site_ids = null)
{
$condition = '';
if ($site_ids !== null) {
if (empty($site_ids)) {
return array();
}
$condition .= db_quote("AND site_id IN (?n)", $site_ids);
}
$sites = db_get_hash_single_array("SELECT * FROM ?:ebay_sites WHERE 1 {$condition}", array('site_id', 'site'));
return $sites;
}
示例8: fn_get_category_desc
function fn_get_category_desc($category_id = 0, $lang_code = CART_LANGUAGE, $as_array = false)
{
if (!empty($category_id)) {
if (!is_array($category_id) && strpos($category_id, ',') !== false) {
$category_id = explode(',', $category_id);
}
if (is_array($category_id) || $as_array == true) {
return db_get_hash_single_array("SELECT category_id, description FROM ?:category_descriptions WHERE category_id IN (?n) AND lang_code = ?s", array('category_id', 'description'), $category_id, $lang_code);
} else {
return db_get_field("SELECT description FROM ?:category_descriptions WHERE category_id = ?i AND lang_code = ?s", $category_id, $lang_code);
}
}
return false;
}
示例9: fn_exim_get_extra_fields
function fn_exim_get_extra_fields($user_id, $lang_code = CART_LANGUAGE)
{
$fields = array();
$_user = db_get_hash_single_array("SELECT d.description, f.value FROM ?:profile_fields_data as f LEFT JOIN ?:profile_field_descriptions as d ON d.object_id = f.field_id AND d.object_type = 'F' AND d.lang_code = ?s WHERE f.object_id = ?i AND f.object_type = 'U'", array('description', 'value'), $lang_code, $user_id);
$_profile = db_get_hash_single_array("SELECT d.description, f.value FROM ?:profile_fields_data as f LEFT JOIN ?:profile_field_descriptions as d ON d.object_id = f.field_id AND d.object_type = 'F' AND d.lang_code = ?s LEFT JOIN ?:user_profiles as p ON f.object_id = p.profile_id AND f.object_type = 'P' WHERE p.user_id = ?i", array('description', 'value'), $lang_code, $user_id);
if (!empty($_user)) {
$fields['user'] = $_user;
}
if (!empty($_profile)) {
$fields['profile'] = $_profile;
}
if (!empty($fields)) {
return YAML_Parser::serialize($fields);
}
return '';
}
示例10: fn_exim_get_features_convert_category_path
/**
* Convert Category names to its IDs
* Example:
* IN array(
* 'some_data' => ...,
* 'categories_path' => 'Electronics,Processors'
* )
* OUT array(
* 'some_data' => ...,
* 'categories_path' => '12,52'
* )
*
* @param array $feature_data List of feature properties
* @param string $lang_code 2-letters lang code
* @return string Converted categories_path
*/
function fn_exim_get_features_convert_category_path($feature_data, $lang_code, $category_delimiter = '///')
{
$categories_path = '';
if (!empty($feature_data['parent_id'])) {
$categories_path = '';
$parent_feature = fn_get_product_feature_data($feature_data['parent_id']);
if (!empty($parent_feature['categories_path'])) {
$categories_path = $parent_feature['categories_path'];
}
} else {
if (!empty($feature_data['categories_path'])) {
$categories_path = array();
if (!isset($categories_ids)) {
$categories_ids = db_get_hash_single_array('SELECT category, category_id FROM ?:category_descriptions WHERE lang_code = ?s', array('category', 'category_id'), $lang_code);
}
$_categories_paths = explode(',', $feature_data['categories_path']);
if (!empty($_categories_paths)) {
foreach ($_categories_paths as $category_path) {
if (strpos($category_path, $category_delimiter)) {
$categories = explode($category_delimiter, $category_path);
array_walk($categories, 'fn_trim_helper');
$cat_ids_path = array();
foreach ($categories as $category) {
if (!empty($categories_ids[$category])) {
$cat_ids_path[] = $categories_ids[$category];
}
}
$cat_ids_path = implode('/', $cat_ids_path);
$__cat_id = db_get_field("SELECT category_id FROM ?:categories WHERE id_path = ?s", $cat_ids_path);
if (!empty($__cat_id)) {
$categories_path[] = $__cat_id;
}
} else {
if (!empty($categories_ids[$category])) {
$categories_path[] = $categories_ids[$category];
}
}
}
}
$categories_path = implode(',', $categories_path);
}
}
return $categories_path;
}
示例11: fn_get_short_companies
function fn_get_short_companies($params = array())
{
$condition = $limit = '';
if (!empty($params['status'])) {
$condition .= db_quote(" AND status = ?s ", $params['status']);
}
if (!empty($params['displayed_vendors'])) {
$limit = 'LIMIT ' . $params['displayed_vendors'];
}
$condition .= defined('COMPANY_ID') ? fn_get_company_condition('company_id', true, COMPANY_ID) : '';
$count = db_get_field('SELECT COUNT(*) FROM ?:companies WHERE 1' . $condition);
$_companies = db_get_hash_single_array("SELECT company_id, company FROM ?:companies WHERE 1 {$condition} ORDER BY company {$limit}", array('company_id', 'company'));
$companies[0] = Registry::get('settings.Company.company_name');
$companies = $companies + $_companies;
$return = array('companies' => $companies, 'count' => $count);
if (!empty($params)) {
unset($return['companies'][0]);
return array($return);
}
return $companies;
}
示例12: preloadLangVars
/**
* Loads received language variables into language cache
*
* @param array $var_names Language variable that to be loaded
* @param string $lang_code 2-letter language code
*
* @return boolean True if any of received language variables were added into cache; false otherwise
*/
public static function preloadLangVars($var_names, $lang_code = CART_LANGUAGE)
{
Registry::registerCache('lang_cache', array('language_values', 'ult_language_values'), Registry::cacheLevel('dispatch'), true);
$values = Registry::get('lang_cache.' . $lang_code);
if (empty($values)) {
$values = array();
}
$var_names = array_diff($var_names, array_keys($values));
if ($var_names) {
foreach ($var_names as $index => $var_name) {
$var_names[$index] = strtolower($var_name);
if (isset($values[$var_name])) {
unset($var_names[$index]);
}
}
if (empty($var_names)) {
return true;
}
$fields = array('lang.name' => true, 'lang.value' => true);
$tables = array('?:language_values lang');
$left_join = array();
$condition = array(db_quote('lang.lang_code = ?s', $lang_code), db_quote('lang.name IN (?a)', $var_names));
$params = array();
fn_set_hook('get_lang_var', $fields, $tables, $left_join, $condition, $params);
$joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
$new_values = db_get_hash_single_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition), array('name', 'value'));
foreach ($var_names as $var_name) {
if (!isset($new_values[$var_name])) {
$new_values[$var_name] = '_' . $var_name;
}
}
$values = fn_array_merge($values, $new_values);
Registry::set('lang_cache.' . $lang_code, $values);
return true;
}
return false;
}
示例13: fn_delete_corresponding_subscription
function fn_delete_corresponding_subscription($order_ids, $not_confirmed = true)
{
$subscriptions = db_get_hash_single_array("SELECT subscription_id, order_id FROM ?:recurring_subscriptions WHERE order_id IN (?n)", array('subscription_id', 'order_id'), $order_ids);
if (!empty($subscriptions)) {
if ($not_confirmed) {
$_SESSION['subscriptions'] = $subscriptions;
$_SESSION['order_ids'] = $order_ids;
return false;
} else {
fn_delete_recurring_subscriptions(array_keys($subscriptions));
}
}
foreach ($order_ids as $v) {
$subs = db_get_array("SELECT subscription_id, order_ids FROM ?:recurring_subscriptions WHERE FIND_IN_SET(?i, order_ids)", $v);
if (!empty($subs)) {
foreach ($subs as $val) {
$new_order_ids = explode(',', $val['order_ids']);
$new_order_ids = array_diff($new_order_ids, $order_ids);
db_query("UPDATE ?:recurring_subscriptions SET order_ids = ?s WHERE subscription_id = ?i", implode(',', $new_order_ids), $val['subscription_id']);
}
}
}
return true;
}
示例14: fn_product_configurator_get_products_post
function fn_product_configurator_get_products_post(&$products)
{
foreach ($products as $pr_id => $product) {
if ($product['product_type'] == 'C') {
$conf_product_groups = db_get_hash_single_array("SELECT ?:conf_product_groups.group_id, ?:conf_product_groups.default_product_ids FROM ?:conf_product_groups LEFT JOIN ?:conf_groups ON ?:conf_product_groups.group_id = ?:conf_groups.group_id WHERE ?:conf_groups.status = 'A' AND ?:conf_product_groups.product_id = ?i", array('group_id', 'default_product_ids'), $product['product_id']);
if (!empty($conf_product_groups)) {
foreach ($conf_product_groups as $k => $v) {
if (!empty($v)) {
$_products = db_get_hash_single_array("SELECT ?:product_prices.product_id, ?:product_prices.price FROM ?:product_prices LEFT JOIN ?:conf_group_products ON ?:conf_group_products.product_id = ?:product_prices.product_id WHERE ?:conf_group_products.group_id = ?i AND ?:product_prices.lower_limit = 1", array('product_id', 'price'), $k);
$tmp = explode(':', $v);
foreach ($tmp as $pid) {
if (!empty($_products[$pid]) && AREA != 'A') {
$products[$pr_id]['price'] += $_products[$pid];
}
}
}
}
}
}
}
return true;
}
示例15: fn_clean_up_addons
/**
* Cleans up addons with incorrect snaphost
*
* @return bool Always true
*/
function fn_clean_up_addons()
{
$_addons = db_get_hash_single_array("SELECT addon, status FROM ?:addons", array('addon', 'status'));
$skipped_snapshots = fn_get_storage_data('skipped_snapshots');
$skipped_snapshots = !empty($skipped_snapshots) ? explode(',', $skipped_snapshots) : array();
foreach ($_addons as $addon => $status) {
$snaphost = md5(str_rot13($addon));
if (!fn_check_addon_snapshot($addon)) {
if ($status == 'A') {
fn_update_addon_status($addon, 'D');
$skipped_snapshots[] = $snaphost;
}
} elseif (in_array($snaphost, $skipped_snapshots)) {
fn_update_addon_status($addon, 'A');
$skipped_snapshots = array_diff($skipped_snapshots, array($snaphost));
}
}
$skipped_snapshots = array_unique($skipped_snapshots);
fn_set_storage_data('skipped_snapshots', implode(',', $skipped_snapshots));
return true;
}