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

32 lines
615 B
PHP

<?php
namespace app\models;
use core\base\Model;
/**
* 销售订单模型
*/
class SalesOrder extends Model
{
protected $table = 'sales_order';
public function getAll()
{
return $this->order(['id DESC'])->fetchAll();
}
public function getById($id)
{
return $this->where(['id = :id'], [':id' => $id])->fetch();
}
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);
}
}