SamplePesticides.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. class SamplePesticides extends Model
  5. {
  6. public function saveItem($data)
  7. {
  8. return parent::saveAll($data);
  9. }
  10. public function getItemByTestIdAndSampleId($test_id, $sample_id)
  11. {
  12. return $this->where([
  13. ['test_id', '=', $test_id],
  14. ['sample_id', '=', $sample_id]
  15. ])
  16. ->failException(false)
  17. ->find();
  18. }
  19. public function getItemBySampleId($sample_id)
  20. {
  21. return $this->where('sample_id', '=', $sample_id)->select();
  22. }
  23. public function saveItemByTestIdAndSampleId($test_id, $sample_id,$data)
  24. {
  25. return $this->where([
  26. ['test_id', '=', $test_id],
  27. ['sample_id', '=', $sample_id]
  28. ])
  29. ->save($data);
  30. }
  31. public function updateItemByTestIdAndSampleId($test_id, $sample_id, $data)
  32. {
  33. $result= $this->where([
  34. ['test_id', '=', $test_id],
  35. ['sample_id', '=', $sample_id]
  36. ])
  37. ->update($data);
  38. return $result;
  39. }
  40. public function saveItemById($id, $data)
  41. {
  42. return $this->where($id)->save($data);
  43. }
  44. }