Countries.php 602 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace Heanup\App\Api\Controller;
  3. use Heanup\App\Api\Config\Code;
  4. use Heanup\App\Api\Controller;
  5. use Heanup\App\Api\Package\Database\Num;
  6. class Countries extends Controller
  7. {
  8. protected function main()
  9. {
  10. $sql="SELECT DISTINCT country FROM `phone_num`";
  11. $db_country=Num::getConnection()->read($sql, []);
  12. $db_country=array_column($db_country, "country");
  13. $db_country=array_fill_keys($db_country, 1);
  14. $this->countries=Code::getData();
  15. $this->countries=array_intersect_key($this->countries, $db_country);
  16. $this->render();
  17. }
  18. }