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;
}
}