php 修改,添加时判断某个字段不能重复

//修改时判断某个字段不能重复
$goods_name_where['id'] = array('neq', $post_data['ids']);
$goods_name_where['goods_name'] = $post_data['goods_name'];
$goods_name_count = db('tf_goods')->where($goods_name_where)->count();
if ($goods_name_count > 0) {
     
    $this->error('产品名称不能重复'); //跳转失败
}

//添加时判断某个字段不能重复
$code = M('dms_lease_goods')->where(array('GoodsCode'=>$_POST['GoodsCode']))->count();
if($code>0){
     
    $this->ajaxReturn('', '商品编码重复', false);
}

你可能感兴趣的:(php,tp5,tp3整理,php)