tinyqc/app/Models/TestModel.php

30 lines
812 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use CodeIgniter\Model;
class TestModel extends Model
{
protected $table = 'dict_test';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['deptid', 'name', 'unit', 'method', 'cva', 'ba', 'tea'];
protected $useTimestamps = false;
public function getByDept($deptid)
{
return $this->where('deptid', $deptid)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_test t');
$builder->select('t.*, d.name as dept_name');
$builder->join('dict_dept d', 'd.id = t.deptid', 'left');
return $builder->get()->getResultArray();
}
}