<?php
 
namespace App\Models;
 
use CodeIgniter\Model;
use App\Models\CountryModel;
use App\Models\StateModel;
use App\Models\CityModel;
 
class CountryStateCityModel extends Model {
 
     
    public function __construct() {
        parent::__construct();
        //$this->load->database();
        $db = \Config\Database::connect();
    }
 
    public function getCountries() {
       $query = $this->db->query('select * from countries');
       return $query->getResult(); 
    }
 
    public function getStates($postData) {
        $builder =$this->db->table('states as st');
        $builder->select('st.*');
        $builder->where('country_id', $postData);
       return $result = $builder->get()->getResult();
    }

    public function getCities($postData) 
    {
        $builder =$this->db->table('cities as ci');
        $builder->select('ci.*');
        $builder->where('state_id', $postData);
        return $result = $builder->get()->getResult();
    }    
 

 
 
}