初始化
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user