Words.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace app\service\model;
  3. use think\Model;
  4. /**
  5. * 快捷语模型
  6. */
  7. class Words extends Model
  8. {
  9. /**
  10. * 数据筛选
  11. *
  12. * @access public
  13. * @param mixed $field 字段
  14. * @param mixed $where 条件
  15. * @return array 返回类型
  16. */
  17. public function selectWords($field, $where=[])
  18. {
  19. $result = $this->field($field);
  20. if (empty($where) === false) {
  21. $result = $result->where($where);
  22. }
  23. $result = $result->select();
  24. return $result;
  25. }//end selectWords()
  26. /**
  27. * 数据修改
  28. *
  29. * @access public
  30. * @param mixed $data 数据
  31. * @param mixed $where 条件
  32. * @return array 返回类型
  33. */
  34. public function updateWords($where, $data)
  35. {
  36. $result = $this->where($where)->update($data);
  37. return $result;
  38. }//end updateWords()
  39. /**
  40. * 数据删除
  41. *
  42. * @access public
  43. * @param mixed $where 条件
  44. * @return array 返回类型
  45. */
  46. public function deleteWords($where)
  47. {
  48. $result = $this->where($where)->delete();
  49. return $result;
  50. }//end deleteWords()
  51. /**
  52. * 数据增加
  53. *
  54. * @access public
  55. * @param mixed $data 数据
  56. * @return array 返回类型
  57. */
  58. public function addWords($data)
  59. {
  60. $result = $this->insertGetId($data);
  61. return $result;
  62. }//end addWords()
  63. /**
  64. * 数据增加
  65. *
  66. * @access public
  67. * @param mixed $where 条件
  68. * @return array 返回类型
  69. */
  70. public function findHas($where)
  71. {
  72. $result = $this->field('id')->where($where)->find();
  73. return $result;
  74. }//end findHas()
  75. }