Upload.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Upload extends BaseModel
  15. {
  16. public function getUploadList($condition, $field = '*')
  17. {
  18. $result = Db::name('upload')->field($field)->order('upload_id asc')->where($condition)->select()->toArray();
  19. return $result;
  20. }
  21. /**
  22. * 取单个内容
  23. * @access public
  24. * @author csdeshang
  25. * @param int $id 分类ID
  26. * @return array 数组类型的返回结果
  27. */
  28. public function getOneUpload($id)
  29. {
  30. $data['upload_id'] = intval($id);
  31. $result = Db::name('upload')->where($data)->find();
  32. return $result;
  33. }
  34. /**
  35. * 新增
  36. * @access public
  37. * @author csdeshang
  38. * @param array $data 参数内容
  39. * @return bool 布尔类型的返回结果
  40. */
  41. public function addUpload($data)
  42. {
  43. $result = Db::name('upload')->insertGetId($data);
  44. return $result;
  45. }
  46. /**
  47. * 更新信息
  48. * @access public
  49. * @author csdeshang
  50. * @param array $data 数据
  51. * @param array $condition 条件
  52. * @return bool
  53. */
  54. public function editUpload($data, $condition)
  55. {
  56. $result = Db::name('upload')->where($condition)->update($data);
  57. return $result;
  58. }
  59. /**
  60. * 删除分类
  61. * @access public
  62. * @author csdeshang
  63. * @param int $condition 记录ID
  64. * @return bool
  65. */
  66. public function delUpload($condition)
  67. {
  68. return Db::name('upload')->where($condition)->delete();
  69. }
  70. }