CityDao.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\store\shipping;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\store\shipping\City as model;
  14. class CityDao extends BaseDao
  15. {
  16. protected function getModel(): string
  17. {
  18. return model::class;
  19. }
  20. /**
  21. * 获取所有符合条件的城市信息
  22. *
  23. * 本函数用于从数据库中查询并返回所有满足给定条件的城市信息。它通过构建一个查询语句,
  24. * 包括指定的条件、排序方式和所需字段,来实现数据的获取。
  25. *
  26. * @param array $where 查询条件数组,用于指定数据库查询的条件。
  27. * @return array 返回一个包含城市信息的数组,每个元素是一个城市的信息。
  28. */
  29. public function getAll(array $where)
  30. {
  31. // 通过模型获取数据库实例,然后构建查询语句,指定查询条件、排序方式和返回字段,最后执行查询。
  32. return ($this->getModel()::getDB())->where($where)->order('id ASC')->field('id,name,code,parent_id')->select();
  33. }
  34. }