33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use CodeIgniter\Model;
|
||
|
|
|
||
|
|
class ControlTestModel extends Model
|
||
|
|
{
|
||
|
|
protected $table = 'control_tests';
|
||
|
|
protected $primaryKey = 'control_test_id';
|
||
|
|
protected $useAutoIncrement = true;
|
||
|
|
protected $returnType = 'array';
|
||
|
|
protected $useSoftDeletes = false;
|
||
|
|
protected $allowedFields = ['control_test_id', 'control_ref_id', 'test_ref_id', 'mean', 'sd'];
|
||
|
|
protected $useTimestamps = false;
|
||
|
|
|
||
|
|
public function getByControl($controlId)
|
||
|
|
{
|
||
|
|
$builder = $this->db->table('control_tests ct');
|
||
|
|
$builder->select('ct.*, t.name as test_name, t.unit');
|
||
|
|
$builder->join('dict_tests t', 't.test_id = ct.test_ref_id');
|
||
|
|
$builder->where('ct.control_ref_id', $controlId);
|
||
|
|
return $builder->get()->getResultArray();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getByControlAndTest($controlId, $testId)
|
||
|
|
{
|
||
|
|
return $this->where('control_ref_id', $controlId)
|
||
|
|
->where('test_ref_id', $testId)
|
||
|
|
->first();
|
||
|
|
}
|
||
|
|
}
|