Files
spacestation/api/controllers/plan/agent/Area.php
T

25 lines
747 B
PHP

<?php
use Overtrue\Pinyin\Pinyin;
class Area extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('area_model');
$this->area_model->set_db('agentdb');
}
public function index()
{
$where = [];
$rows = $this->area_model->select($where, 'id asc', '', '', 'DISTINCT city_id,city_name');
$pinyin = new Pinyin();
foreach ($rows as $row) {
$firstLetter = $pinyin->abbr($row['city_name']);
$firstchar = strtoupper(substr($firstLetter, 0, 1));
$this->area_model->update(['firstchar'=>$firstchar],['city_id'=>$row['city_id']]);
}
echo '执行完成';
}
}