HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/RClaassen/stay-on-track.nl/wwwroot/vacatures/application/models/bedrijven/land.php
<?php
class Land extends CI_Model {
	public function __construct() {
		$this->load->database();
	}

	public function recordCount() {
		return $this->db->count_all("countries");
	}

	public function getLanden($limit, $start) {
		$this->db->select('id, naam, iso2, iso3');
		$this->db->from('countries');
		$this->db->order_by('naam', 'ASC');
		$this->db->limit($limit, $start);
		$result = $this->db->get();
		$landen = array();
		foreach($result->result() as $land) {
			$landen[] = $land;
		}
		return $landen;
	}

	public function getLandById($id) {
	        $this->db->select('countries.*');
        	$this->db->from('countries');
		$this->db->where('countries.id', $id);
		return $this->db->get();
	}

	public function saveLand ($land) {
		if(intval($land['id']) <= 0)  {
			unset($land['id']);
			$this->db->insert('countries', $land);
		} else {
			$this->db->where('id', $land['id']);
			$this->db->update('countries', $land);
		}
	}
	public function delete($id) {	
		$this->db->where('id', $id);
		$this->db->delete('countries');
	}

	public function getSearch($zoekterm) {
		$this->db->select('id, naam');
		$this->db->from('countries');
		$this->db->like('naam', $zoekterm);
		$this->db->or_like('iso2', $zoekterm);
		$this->db->or_like('iso3', $zoekterm);
		$landen = array();
		$result = $this->db->get();
		foreach($result->result() as $land) {
			$landen[] = array('id' => $land->id, 'label' => $land->naam);
		}
		return $landen;
	}
}