分享好友 教程首页 教程搜索 频道列表

DESTOON调用公司设置任意字段信息的方案

2016-10-13 14:1927051
+关注28
核心提示:把以下函数加入到api/extend.func.php

1、这是商铺的设置参数

把以下函数加入到api/extend.func.php 中

//获取公司setting表里的值
function xh_com_setting($userid, $key = '', $cache = '') {
    global $db;
    if($key) {
        $r = $db->get_one("SELECT * FROM {$db->pre}company_setting WHERE userid=$userid AND item_key='$key'", $cache);
        return $r ? $r['item_value'] : '';
    } else {
        $setting = array();
        if($cache) {
            $query = $db->query("SELECT * FROM {$db->pre}company_setting WHERE userid=$userid AND item_key<>'mypage'", $cache);
        } else {
            $query = $db->query("SELECT * FROM {$db->pre}company_setting WHERE userid=$userid", $cache);
        }
        while($r = $db->fetch_array($query)) {
            $setting[$r['item_key']] = $r['item_value'];
        }
        return $setting;
    }
}



然后使用

{xh_com_setting($t[userid], '字段')}


在公司列表循环中调用

比如在公司列表页调用 公司自定义LOGO

{xh_com_setting($t[userid] ,'logo')}


调取时详情用

{php $xh = userinfo($username);}
{getcom_item($xh[userid], 'logo')}



2、其他模块调取公司表的参数

把以下函数加入到api/extend.func.php 中

//获取公司表的值
function xh_company($userid, $key = '') {
    global $db;
    if($key) {
        $r = $db->get_one("SELECT `$key` FROM {$db->pre}company WHERE userid=$userid");
        return $r ? $r[$key] : '';
    } 
}


在其他模块调取(主要是先得到用户名 username)

如:公司主营(列表方式)

{php $xh = userinfo($t[username]);}
{xh_company($xh[userid], 'business')}


如:公司主营(详情方式)

{php $xh = userinfo($username);}
{xh_company($xh[userid], 'business')}


本文标签: #公司字段 #跨表
整理员:小黑
免责声明:凡注明来源本网的所有作品,均为本网合法拥有版权或有权使用的作品,欢迎转载,注明出处。非本网作品均来自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。
生成海报
相关评论1
您可能在找更多
下一篇
我来说两句
1