/** * 图片资料删除(删除数据) * @parm $id:int 衣服id(beu_clothes的id) * @return 成功返回true,否则返回false * json解码后的数据规范 array( 'customImagecontent'=>array( 'customimage1'=>array( 0=>'', 1=>'' ) ), 'staticImagecontent'=>array( 0=>'', 1=>'' ), 'detailImagecontent'=>array( 0=>'', 1=>'' ), 'graphicmodel'=>array( 0=>'', 1=>'' ), 'collocationmap'=>array( 0=>'', 1=>'' ) ) */ private static function clothesDeleteImg($id = 0) { $id = trim($id); try { Comm::checkValue($id, Yii::t('clothes', '衣服ID'), 1, 1, self::$Int_max); } catch (Exception $e) { throw new BeubeuException($e->getMessage(), $e->getCode()); } $arr = uploadd::SessionGet($id, self::$Img_Delete_Session_name); //获取session里的暂存数据 if ($arr) { $arr = trim($arr); if (!empty($arr)) { $arr = json_decode($arr, true); if (count($arr) > 0) { try { $data = Yii::app()->db->createCommand()->select('imagescontent')->from('beu_clothes')->where('id=:id', array(':id' => $id))->queryAll(); $imagescontent = array(); if (count($data) > 0) { $imagescontent = trim($data[0]['imagescontent']); if (!empty($imagescontent)) { $ftp = new classftp(); $imagescontent = json_decode($imagescontent, true); $arr_jj = Comm::my_array_key_intersection($imagescontent, $arr); //根据键找到两个数组的交集,返回值只是第一个数组 Comm::arrayDelete($arr_jj); //删除需要被替换的文件 $arr_cj = Comm::my_array_key_diff($imagescontent, $arr_jj); //找到原有数据不变的数组 $arr_hb = self::ImgSort($arr_hb); //对数组进行排序 $imagescontent = json_encode($arr_cj); if ($imagescontent != $data[0]['imagescontent']) { beu_clothes::model()->updateByPk($id, array('imagescontent' => $imagescontent)); } } } return true; } catch (Exception $e) { throw new BeubeuException(Yii::t('public', '查询数据失败'), BeubeuException::SQL_SELECT_ERR); } } else { throw new BeubeuException(Yii::t('beu_brand', '数据') . Yii::t('public', '不能为空'), BeubeuException::FIELD_EMPTY); } } } }