//遍历更新 foreach ($list as $key => $value) { $value['goodsname'] = $this->trimall($value['goodsname']); $value['measureunit'] = $this->trimall($value['measureunit']); $goodsLogic->saveByData($value,array('id'=>$value['id'])); }
/** * 说明:新增/修改 * 作者: panzhide * 时间: 2020/8/14 * @param string $where * @return string */ public static function saveByData($data, $where = []) { $model = BaseModelFactory::create('Goods', 'stock'); $res = $model->allowField(true)->save($data, $where); return $res; }
//删除空格 public function trimall($str) { $oldchar=array(" "," "," "," "," "); $newchar=array("","","","",""); return str_replace($oldchar,$newchar,$str); }