Files
MES/app/models/HrEmployee.php
T
2026-08-08 18:28:49 +08:00

42 lines
941 B
PHP

<?php
namespace app\models;
use core\base\Model;
/**
* 人事档案模型
*/
class HrEmployee extends Model
{
protected $table = 'hr_employee';
public function getAll()
{
return $this->order(['id DESC'])->fetchAll();
}
public function getById($id)
{
return $this->where(['id = :id'], [':id' => $id])->fetch();
}
public function getByDepartment($department)
{
return $this->where(['department = :dept'], [':dept' => $department])->order(['id DESC'])->fetchAll();
}
public function getByStatus($status)
{
return $this->where(['status = :st'], [':st' => $status])->order(['id DESC'])->fetchAll();
}
public function getCount()
{
$sql = 'SELECT COUNT(*) AS cnt FROM ' . $this->getTable();
$stmt = $this->pdo->prepare($sql);
$stmt->execute();
$row = $stmt->fetch();
return (int)($row['cnt'] ?? 0);
}
}