obj =& get_instance(); // Initialise or clear class variables. // NOTE: Not particularly useful unless you are using model persistence $this->_init_Subcategoria(); } // ////////////////////////////////////////////////////////////////////////// // Function: findAll() // // Description: Retrieves and returns data listing from the database // // ////////////////////////////////////////////////////////////////////////// function findAll($start = NULL, $count = NULL) { return $this->find(NULL, $start, $count); } // function findById($key_value) { // return $this->find(array('id' => '$key_value')); // } function findByFilter($filter_rules, $start = NULL, $count = NULL) { return $this->find($filter_rules, $start, $count); } function find($filters = NULL, $start = NULL, $count = NULL) { $results = array(); // Load the database library $this->load->database(); // /////////////////////////////////////////////////////////////////////// // Make a note of the current table record count // /////////////////////////////////////////////////////////////////////// $this->table_record_count = $this->db->count_all( 'subcategoria' ); // Filter could be an array or filter values or an SQL string. $where_clause = ''; if ($filters) { if ( is_string($filters) ) { $where_clause = $filters; } elseif ( is_array($filters) ) { // Build your filter rules if ( count($filters) > 0 ) { foreach ($filters as $field => $value) { $filter_list[] = " $field = '$value' "; } $where_clause = "WHERE " . join(' AND ', $filter_list ); } } } $limit_clause = ''; if ($start) { if ($count) { $limit_clause = " LIMIT $start, $count "; } else { $limit_clause = " LIMIT $start "; } } $order=' order by dessubcategoria '; // Build up the SQL query string and run the query $sql = 'SELECT * FROM subcategoria ' . $where_clause . $order .$limit_clause; $query = $this->db->query($sql); if ($query->num_rows() > 0) { // //////////////////////////////////////////////////////////////////// // NOTE: At this stage you could return the entire result set, like: // NOTE: ...return $query->result_array(); // NOTE: ...The generated code loops through the result set to provide // NOTE: ...the oppurtunity to provide further customisations on the // NOTE: ...code (especially if you are generating in verbose mode). // //////////////////////////////////////////////////////////////////// foreach ($query->result_array() as $row) // Go through the result set { // Build up a list for each column from the database and place it in // ...the result set $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['idcategoria'] = $row['idcategoria']; $query_results['ver'] = $row['ver']; $query_results['check'] = $row['check']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } // TODO: this won't be possible if there is no primary key for the table. function retrieve_by_pkey($idField) { $results = array(); // Load the db library $this->load->database(); $query = $this->db->query("SELECT * FROM subcategoria WHERE idsubcategoria = '$idField' LIMIT 1"); if ($query->num_rows() > 0) { $row = $query->row_array(); $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['idcategoria'] = $row['idcategoria']; $query_results['ver'] = $row['ver']; $query_results['check'] = $row['check']; $query_results['icono'] = $row['icono']; $results = $query_results; } else { $results = false; } return $results; } function add( $data ) { // Load the database library $this->load->database(); // Build up the SQL query string $sql = $this->db->insert_string('subcategoria', $data); $query = $this->db->query($sql); return $this->db->insert_id(); } function modify($keyvalue, $data) { // Load the database library $this->load->database(); // Build up the SQL query string $where = "idsubcategoria = $keyvalue"; $sql = $this->db->update_string('subcategoria', $data, $where); $query = $this->db->query($sql); } function delete_by_pkey($idField) { // Load the db library $this->load->database(); // /////////////////////////////////////////////////////////////////////// // TODO: Just to eliminate nasty mishaps, the delete query has been // TODO: ...deliberately disabled. Enable it if you mean to by uncommenting // TODO: ...the query function call below // /////////////////////////////////////////////////////////////////////// // $query = $this->db->query("DELETE FROM hotels WHERE id = '$idField' "); return true; } public function get_Idsubcategoria() { return $this->idsubcategoria; } public function set_Idsubcategoria($idsubcategoria) { $this->idsubcategoria = $idsubcategoria; } function get_Dessubcategoria_en() { return $this->dessubcategoria_en; } function set_Dessubcategoria_en($dessubcategoria_en) { $this->dessubcategoria_en = $dessubcategoria_en; } function get_Dessubcategoria() { return $this->dessubcategoria; } function set_Dessubcategoria($dessubcategoria) { $this->dessubcategoria = $dessubcategoria; } public function get_Idcategoria() { return $this->idcategoria; } public function set_Idcategoria($idcategoria) { $this->idacategoria = $idcategoria; } function get_Ver() { return $this->ver; } function set_Ver($ver) { $this->ver = $ver; } function get_Check() { return $this->check; } function set_Check($check) { $this->check = $check; } // Function used to initilialise class variables. // NOTE: Not particularly useful unless you are using model persistence // NOTE: You may want to add default values here. function _init_Subcategoria() { $this->idsubcategoria = ""; $this->idcategoria = ""; $this->dessubcategoria_en = ""; $this->dessubcategoria = ""; $this->ver = ""; $this->check = ""; } // Initialize all your default variables here // Function used to initilialise class variables. // NOTE: Not particularly useful unless you are using model persistence // NOTE: You could add default values here, but fields are generally set empty function _emptyCategoria() { $this->idsubcategoria = ""; $this->idcategoria = ""; $this->dessubcategoria_en = ""; $this->dessubcategoria = ""; $this->ver = ""; $this->check = ""; } } ?>