示例#1
0
 /**
  * 图片上传资料整理(与数据库对比后返回的更新到数据库的json数据)
  * @param $id:int 品牌id	
  * @return 成功返回整理后的json数据,否则返回false
  */
 private static function brandImgUp($id = 0)
 {
     $id = trim($id);
     try {
         Comm::checkValue($id, 'ID', 1, 1);
     } catch (Exception $e) {
         return false;
     }
     $arr = uploadd::SessionGet($id, self::$Img_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('logoimgpath')->from('beu_brand')->where('id=:id', array(':id' => $id))->queryAll();
                     if ($data[0]['logoimgpath'] != '') {
                         Comm::arrayDelete($data[0]['logoimgpath']);
                         //删除需要被替换的文件
                     }
                 } catch (Exception $e) {
                 }
                 return json_encode($arr);
             }
         }
     }
     return false;
 }
示例#2
0
 /**
  * 清理缓存sessin数据
  * @param $id 衣服id
  * @param $type 谁用 例:clothesVoid
  */
 public static function SessionDelete($id = 0, $type = '')
 {
     $id = trim($id);
     $type = trim($type);
     try {
         Comm::checkValue($id, 'ID', 1, 1);
         Comm::checkValue($type, '', 0, 1);
     } catch (Exception $e) {
         return false;
     }
     if ($id == 999999999) {
         $id = session_id();
     }
     if (isset($_SESSION[$type . $id])) {
         $json_data = $_SESSION[$type . $id];
         $json_data = trim($json_data);
         if (!empty($json_data)) {
             $json_data = json_decode($json_data, true);
             Comm::arrayDelete($json_data);
             $arr = Comm::array_multi2single($json_data);
             //将多维数组转一维
             array_unique($arr);
             //去重
             Imgcaches::imgCacheDeleteByimg($arr);
             //从数组中删除数据
             try {
                 unset($_SESSION[$type . $id]);
             } catch (Exception $e) {
             }
         }
     }
 }
示例#3
0
 /**
 * 图片资料删除(删除数据)
 * @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);
             }
         }
     }
 }