Fleaupload.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Fleaupload extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 取单个内容
  19. * @access public
  20. * @author csdeshang
  21. * @param int $id 分类ID
  22. * @return array 数组类型的返回结果
  23. */
  24. public function getOneFleaupload($id)
  25. {
  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. {
  38. if (empty($data)) {
  39. return false;
  40. }
  41. if (is_array($data)) {
  42. $result = Db::name('fleaupload')->insertGetId($data);
  43. return $result;
  44. } else {
  45. return false;
  46. }
  47. }
  48. /**
  49. * 更新信息
  50. * @access public
  51. * @author csdeshang
  52. * @param array $data 更新数据
  53. * @param array $condition 条件数组
  54. * @return bool 布尔类型的返回结果
  55. */
  56. public function editFleaupload($data, $condition)
  57. {
  58. $result = Db::name('fleaupload')->where($condition)->update($data);
  59. return $result;
  60. }
  61. /**
  62. * 删除图片信息,根据where
  63. * @access public
  64. * @author csdeshang
  65. * @param array $condition 条件数组
  66. * @return bool 布尔类型的返回结果
  67. */
  68. public function delFleaupload($condition, $store_id)
  69. {
  70. if (empty($condition)) {
  71. return false;
  72. }
  73. $image_more = Db::name('fleaupload')->where($condition)->field('fleafile_name')->select()->toArray();
  74. if (is_array($image_more) && !empty($image_more)) {
  75. foreach ($image_more as $v) {
  76. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_MFLEA . DIRECTORY_SEPARATOR . $store_id . DIRECTORY_SEPARATOR . $v['fleafile_name']);
  77. }
  78. }
  79. $state = Db::name('fleaupload')->where($condition)->delete();
  80. return $state;
  81. }
  82. }