Upload.php 1.7 KB

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