企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 通过款号ID查询对应的分类名称 **位置:** Common\Common\function.php jig 2018-07-03 **参数:** * @param int $spu_id spu_id * @param int $level 分类等级 1:性别 2:大类 3:中类 4:小类 默认小类 * @param int $ret_type 返回类型 1:分类名 2:分类ID 默认分类名 * * @return string **调用:** > PHP 调用: spu_cat_info ($spu_id) > View 模版调用: {$vo['spu_id']|spu_cat_info} **完整代码:** ~~~ /** * 通过款号ID查询对应的分类名称 * jig 2018-07-03 * * @param int $spu_id spu_id * @param int $level 分类等级 1:性别 2:大类 3:中类 4:小类 默认小类 * @param int $ret_type 返回类型 1:分类名 2:分类ID 默认分类名 * * @return string */ function spu_cat_info ($spu_id, $level = 4, $ret_type = 1) { if (empty($spu_id)) { return false; } $result = M('goods_category as c') ->field('c.id as cid, c.cat_name') ->join("coscia_goods_spu_category as sc on sc.cat_id = c.id", 'LEFT') ->where(array('sc.spu_id' => $spu_id, 'c.level' => $level)) ->find(); if (!empty($result)) { return ($ret_type == 2) ? $result['cid'] : $result['cat_name'] ; } } ~~~