32 lines
615 B
PHP
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);
|
|
}
|
|
}
|