Fleaupload.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Fleaupload extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 取单个内容
  16. * @access public
  17. * @author csdeshang
  18. * @param int $id 分类ID
  19. * @return array 数组类型的返回结果
  20. */
  21. public function getOneFleaupload($id)
  22. {
  23. $result = Db::name('fleaupload')->where(array('fleaupload_id' => intval($id)))->find();
  24. return $result;
  25. }
  26. /**
  27. * 新增
  28. * @access public
  29. * @author csdeshang
  30. * @param array $data 参数内容
  31. * @return bool 布尔类型的返回结果
  32. */
  33. public function addFleaupload($data)
  34. {
  35. if (empty($data)) {
  36. return false;
  37. }
  38. if (is_array($data)) {
  39. $result = Db::name('fleaupload')->insertGetId($data);
  40. return $result;
  41. } else {
  42. return false;
  43. }
  44. }
  45. /**
  46. * 更新信息
  47. * @access public
  48. * @author csdeshang
  49. * @param array $data 更新数据
  50. * @param array $condition 条件数组
  51. * @return bool 布尔类型的返回结果
  52. */
  53. public function editFleaupload($data, $condition)
  54. {
  55. $result = Db::name('fleaupload')->where($condition)->update($data);
  56. return $result;
  57. }
  58. /**
  59. * 删除图片信息,根据where
  60. * @access public
  61. * @author csdeshang
  62. * @param array $condition 条件数组
  63. * @return bool 布尔类型的返回结果
  64. */
  65. public function delFleaupload($condition, $store_id)
  66. {
  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. }