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

37 lines
784 B
PHP

<?php
namespace app\models;
use core\base\Model;
/**
* 应收应付账款模型
*/
class ReceivablePayable extends Model
{
protected $table = 'receivable_payable';
public function getAll()
{
return $this->order(['id DESC'])->fetchAll();
}
public function getById($id)
{
return $this->where(['id = :id'], [':id' => $id])->fetch();
}
public function getByType($type)
{
return $this->where(['type = :type'], [':type' => $type])->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);
}
}