123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\api\model;
- use think\Model;
- class SamplePesticides extends Model
- {
- public function saveItem($data)
- {
- return parent::saveAll($data);
- }
- public function getItemByTestIdAndSampleId($test_id, $sample_id)
- {
- return $this->where([
- ['test_id', '=', $test_id],
- ['sample_id', '=', $sample_id]
- ])
- ->failException(false)
- ->find();
- }
- public function getItemBySampleId($sample_id)
- {
- return $this->where('sample_id', '=', $sample_id)->select();
- }
- public function saveItemByTestIdAndSampleId($test_id, $sample_id,$data)
- {
- return $this->where([
- ['test_id', '=', $test_id],
- ['sample_id', '=', $sample_id]
- ])
- ->save($data);
- }
- public function updateItemByTestIdAndSampleId($test_id, $sample_id, $data)
- {
- $result= $this->where([
- ['test_id', '=', $test_id],
- ['sample_id', '=', $sample_id]
- ])
- ->update($data);
- return $result;
- }
- public function saveItemById($id, $data)
- {
- return $this->where($id)->save($data);
- }
- }
|