| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace Admin\Model;
- use Common\Model\ModelModel;
- /**
- * 配置模型
- *
- */
- class BarLargeModel extends ModelModel
- {
- /**
- * 数据库表名
- *
- */
- protected $tableName = 'bar_large';
- /**
- * 自动验证规则
- *
- */
- protected $_validate = array(
- /*array('code', 'require', '产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
- array('code', '4,6', '产品代码长度为4-6个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
- array('code', '', '产品代码已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
- array('title', 'require', '自定义名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
- array('title', '', '自定义名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),*/
- );
- /**
- * 自动完成规则
- *
- */
- protected $_auto = array(
- );
- /**
- * 获取大件
- * @return array 配置数组
- *
- */
- public function getList($where = [],$p)
- {
- $list = $this->where($where)->order('id desc')->limit($p->firstRow, $p->listRows)->select();
- return $list;
- }
- public function slectById($id){
- $list = $this->where('id ='.$id)->select();
- return $list;
- }
- public function getById($list){
- header("Content-type: text/html; charset=utf-8");
- $where = array();
- $where['id'] = array('in',$list);
- $field = "sn,name,time,num,standard,inspector,batch_number,board_no,tray_no,quality_no";
- $data = $this->field($field)->where($where)->select();
- $new = array();
- foreach($data as $v){
- $arr = array();
- $arr = $v;
- $arr['custome_name'] = '湖北中烟工业有限公司';
- $arr['date'] = date('Y',$v['time']).'年'.date('m',$v['time']).'月'.date('d',$v['time']).'日';
- $arr['sn'] = preg_replace("/[\(\)]/","",$v['sn']);
- unset( $arr['time']);
- $new[]= $arr;
- }
- return $new;
- }
- /*保存产品信息*/
- public function save1($data){
- $id = $data['id'];
- if($id){
- //执行更新
- $return = $this->where('id ='.$id)->save($data);
- }else{
- //执行增加
- unset($data['id']);
- $return = $this->add($data);
- }
- if($return!==false){
- return true;
- }
- return false;
- }
- }
|