obj =& get_instance(); } function findAll() { $results = array(); // Load the db library $this->load->database(); $sql=' select idgrupo, g.nombre as nombregrupo,g.nombre_en as nombregrupo_en, tipo, sg.id as idsubgrupo, sg.nombre as nombresubgrupo, sg.nombre_en as nombresubgrupo_en from grupo g, subgrupo sg where g.id=sg.idgrupo order by g.tipo, g.id, sg.id '; $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['idgrupo'] = $row['idgrupo']; $query_results['nombregrupo'] = $row['nombregrupo']; $query_results['nombregrupo_en'] = $row['nombregrupo_en']; $query_results['tipo'] = $row['tipo']; $query_results['idsubgrupo'] = $row['idsubgrupo']; $query_results['nombresubgrupo'] = $row['nombresubgrupo']; $query_results['nombresubgrupo_en'] = $row['nombresubgrupo_en']; $results[] = $query_results; } } return $results; } function findAllByTipo($tipo) { $results = array(); // Load the db library $this->load->database(); $sql="select idgrupo, g.nombre as nombregrupo,g.nombre_en as nombregrupo_en, tipo, sg.id as idsubgrupo, sg.nombre as nombresubgrupo, sg.nombre_en as nombresubgrupo_en from grupo g, subgrupo sg where sg.idgrupo=g.id and tipo='$tipo' order by g.id, sg.id "; $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['idgrupo'] = $row['idgrupo']; $query_results['nombregrupo'] = $row['nombregrupo']; $query_results['nombregrupo_en'] = $row['nombregrupo_en']; $query_results['tipo'] = $row['tipo']; $query_results['idsubgrupo'] = $row['idsubgrupo']; $query_results['nombresubgrupo'] = $row['nombresubgrupo']; $query_results['nombresubgrupo_en'] = $row['nombresubgrupo_en']; $results[] = $query_results; } } return $results; } //Para seleccionar los que tiene grabados el local function findAllByTipo2($tipo, $idinfo) { $results = array(); // Load the db library $this->load->database(); $sql="select idgrupo, g.nombre as nombregrupo,g.nombre_en as nombregrupo_en, tipo, sg.id as idsubgrupo, sg.nombre as nombresubgrupo, sg.nombre_en as nombresubgrupo_en, (select id from subgrupo_info i where i.idinfo=$idinfo and i.idsubgrupo=sg.id limit 1 ) as idsubgrupoinfo from grupo g, subgrupo sg where sg.idgrupo=g.id and tipo='$tipo' order by g.id, sg.id "; $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['idgrupo'] = $row['idgrupo']; $query_results['nombregrupo'] = $row['nombregrupo']; $query_results['nombregrupo_en'] = $row['nombregrupo_en']; $query_results['tipo'] = $row['tipo']; $query_results['idsubgrupo'] = $row['idsubgrupo']; $query_results['nombresubgrupo'] = $row['nombresubgrupo']; $query_results['nombresubgrupo_en'] = $row['nombresubgrupo_en']; $query_results['idsubgrupoinfo'] = $row['idsubgrupoinfo']; $results[] = $query_results; } } return $results; } function deleteByIdInfo($idInfo) { $results = array(); $this->load->database(); $sql="delete from subgrupo_info where idinfo= $idInfo "; $res=$query = $this->db->query($sql); return $res; } function add( $data ) { try{ // Load the database library $this->load->database(); // Build up the SQL query string $sql = $this->db->insert_string('subgrupo_info', $data); $query = $this->db->query($sql); return $this->db->insert_id(); }catch(Exception $e){ echo "error"; return -1; } } } ?>