文件
mashangyoujiu/Application/Common/Model/CateModel.class.php

42 行
1.4 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Common\Model;
use Think\Model;
class CateModel extends Model{
protected $tableName = 'retail_goods_class';
protected $fields = array(
'id', //int(11) NOT NULL AUTO_INCREMENT,
'pid', // int(11) DEFAULT '0' COMMENT '父级分类id',
'class_name', // varchar(255) DEFAULT NULL COMMENT '零售商品分类名:',
'addtime', // int(11) DEFAULT NULL COMMENT '添加时间',
'merchantid', // int(11) DEFAULT NULL COMMENT '商户id',
'status', // int(1) unsigned zerofill DEFAULT '0' COMMENT '状态:0,正常,1,删除。',
'code', // varchar(18) DEFAULT NULL COMMENT '编码;每个门店从1开始生成,可用作排序'
);
public function catetree($map,$limit){
$data=$this->where($map)->limit($limit)->select();
return $this->catesTree($data);
}
public function getCount($map){
$data=$this->where($map)->count();
return $data;
}
public function catesTree($data,$parentid=0,$level=0,$nbsp = '--'){
static $tree=array();
foreach ($data as $k=>$v){
if($v['pid']==$parentid){
$v['level']=$level;
$v['nbsp'] = str_repeat( $nbsp, $level );
$tree[]=$v;
unset($data[$k]);
$this->catesTree($data,$v['id'],$level+1);
}
}
return $tree;
}
}