SamplePesticides.php 816 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }