52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
namespace Admin\Model;
|
|
use Think\Model\RelationModel;
|
|
class FlowModel extends RelationModel{
|
|
|
|
|
|
protected $_link = array(
|
|
"who_add"=>array(
|
|
'mapping_type' => self::BELONGS_TO,
|
|
'class_name' => 'user',
|
|
'mapping_fields' => 'user_name',
|
|
'foreign_key' => 'flow_who_add',
|
|
),
|
|
"who_modify"=>array(
|
|
'mapping_type' => self::BELONGS_TO,
|
|
'class_name' => 'user',
|
|
'mapping_fields' => 'user_name',
|
|
'foreign_key' => 'flow_who_modify',
|
|
),
|
|
|
|
);
|
|
|
|
//验证
|
|
protected $_validate=array(
|
|
//array("字段","验证规则","错误提示",["验证条件","附加条件","验证时间"]),
|
|
array("flow_name","require","工艺流程名称不能为空"),
|
|
array("flow_code","require","工艺流程代码不能为空"),
|
|
array("flow_name","","工艺流程名称已存在",0,"unique"),
|
|
array("flow_code","","工艺流程代码已存在",0,"unique"),
|
|
);
|
|
//保存信息
|
|
public function data_save(){
|
|
//创建数据
|
|
$data=$this->create();
|
|
$member_id = UID;
|
|
$data['flow_who_modify'] = $member_id;
|
|
$data['flow_time_modify'] = time();
|
|
$this->data($data)->save();
|
|
return $data['flow_id'];
|
|
}
|
|
//保存信息
|
|
public function data_add(){
|
|
//创建数据
|
|
$data=$this->create();
|
|
unset($data['flow_id']);
|
|
$member_id = UID;
|
|
$data['flow_who_add'] = $member_id;
|
|
$data['flow_time_add'] = time();
|
|
$id = $this->data($data)->add();
|
|
return $id;
|
|
}
|
|
} |