1: <?php
2: class Services_Model extends CI_Model {
3: 4: 5:
6: function __construct() {
7: parent::__construct();
8: }
9:
10: 11: 12: 13: 14: 15: 16: 17:
18: public function get_row($service_id) {
19: if (!is_numeric($service_id)) {
20: throw new InvalidArgumentException('$service_id argument is not an integer : ' . $service_id);
21: }
22: return $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
23: }
24:
25: 26: 27: 28: 29: 30: 31: 32:
33: public function get_value($field_name, $service_id) {
34: if (!is_numeric($service_id)) {
35: throw new InvalidArgumentException('Invalid argument provided as $service_id : ' . $service_id);
36: }
37:
38: if (!is_string($field_name)) {
39: throw new InvalidArgumentException('$field_name argument is not a string : ' . $field_name);
40: }
41:
42: if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) {
43: throw new InvalidArgumentException('The record with the $service_id argument does not exist in the database : ' . $service_id);
44: }
45:
46: $row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
47: if (!isset($row_data[$field_name])) {
48: throw new InvalidArgumentException('The given $field_name argument does not exist in the database : ' . $field_name);
49: }
50:
51: return $this->db->get_where('ea_services', array('id' => $service_id))->row_array()[$field_name];
52: }
53:
54: 55: 56: 57: 58: 59: 60: 61: 62:
63: public function get_batch($where_clause = NULL) {
64: if ($where_clause != NULL) {
65: $this->db->where($where_clause);
66: }
67:
68: return $this->db->get('ea_services')->result_array();
69: }
70:
71: 72: 73: 74: 75: 76:
77: function get_available_services() {
78: return $this->db->get('ea_services')->result_array();
79: }
80: }
81:
82:
83:
84: