数据库数值显得文字

来源:互联网 发布:皇甫圣华的淘宝店网址 编辑:程序博客网 时间:2024/05/02 00:14

数据库中type为数值,现在让其显示为图片和文字

这为显示的view层的代码

array(

'header'=>'类型',
'type'=>'html',
'value'=>'$data->getHasType()',
'htmlOptions'=>array(
              'width'=>'70',
              'style'=>'text-align:left',
        ),

),

下面在model里面创立这个方法

首先对type的数值进行判断,然后返回

public function getHasType()
 {
    if ($this->type==1)
       return '文字';
    elseif($this->type==2)
       return '图片';
    else 
       return '信息丢失';
}

原创粉丝点击