Fleaupload.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Fleaupload extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 取单个内容
  20. * @access public
  21. * @author csdeshang
  22. * @param int $id 分类ID
  23. * @return array 数组类型的返回结果
  24. */
  25. public function getOneFleaupload($id){
  26. $result = Db::name('fleaupload')->where(array('fleaupload_id'=>intval($id)))->find();
  27. return $result;
  28. }
  29. /**
  30. * 新增
  31. * @access public
  32. * @author csdeshang
  33. * @param array $data 参数内容
  34. * @return bool 布尔类型的返回结果
  35. */
  36. public function addFleaupload($data){
  37. if (empty($data)){
  38. return false;
  39. }
  40. if (is_array($data)){
  41. $result = Db::name('fleaupload')->insertGetId($data);
  42. return $result;
  43. }else {
  44. return false;
  45. }
  46. }
  47. /**
  48. * 更新信息
  49. * @access public
  50. * @author csdeshang
  51. * @param array $data 更新数据
  52. * @param array $condition 条件数组
  53. * @return bool 布尔类型的返回结果
  54. */
  55. public function editFleaupload($data, $condition) {
  56. $result = Db::name('fleaupload')->where($condition)->update($data);
  57. return $result;
  58. }
  59. /**
  60. * 删除图片信息,根据where
  61. * @access public
  62. * @author csdeshang
  63. * @param array $condition 条件数组
  64. * @return bool 布尔类型的返回结果
  65. */
  66. public function delFleaupload($condition , $store_id){
  67. if (empty($condition)) {
  68. return false;
  69. }
  70. $image_more = Db::name('fleaupload')->where($condition)->field('fleafile_name')->select()->toArray();
  71. if (is_array($image_more) && !empty($image_more)) {
  72. foreach ($image_more as $v) {
  73. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_MFLEA . DIRECTORY_SEPARATOR . $store_id . DIRECTORY_SEPARATOR . $v['fleafile_name']);
  74. }
  75. }
  76. $state = Db::name('fleaupload')->where($condition)->delete();
  77. return $state;
  78. }
  79. }