obj =& get_instance(); $this->_init_Relsubcat(); } function findAllData(){ $results = array(); $ciu=$this->ubica->ciu; //ciu=$ciu // Load the db library $this->load->database(); $sql=" select * from categoria cat order by descategoria "; $query = $this->db->query($sql); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) // Go through the result set { $query_results['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['tipo'] = $row['tipo']; $query_results["subcategorias"]= $this->subcatByCategoria($row['idcategoria']); $results[] = $query_results; } } return $results; } function subcatByCategoria($idCategoria){ $results = array(); $ciu=$this->ubica->ciu; //ciu=$ciu // Load the db library $this->load->database(); $sql=" select sub.idSubCategoria,sub.dessubcategoria,sub.dessubcategoria_en,sub.idcategoria, count(i) as num, sub.check, sub.icono from subcategoria sub, informacion i where i.idSubCat=sub.idSubCategoria and i.ciu=1 and idcategoria=$idCategoria group by sub.idSubCategoria,sub.dessubcategoria, sub.dessubcategoria_en,sub.idcategoria, sub.check, sub.icono order by sub.idSubCategoria"; $query = $this->db->query($sql); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) // Go through the result set { $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['num'] = $row['num']; $query_results['check'] = $row['check']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } function findAll() { $results = array(); $ciu=$this->ubica->ciu; //ciu=$ciu // Load the db library $this->load->database(); $sql=" select cat.idcategoria,cat.descategoria, cat.descategoria_en, sub.idsubcategoria, sub.dessubcategoria,sub.dessubcategoria_en, num, sub.check, sub.icono from( select sub.idSubCategoria,sub.dessubcategoria,sub.dessubcategoria_en,sub.idcategoria, count(i) as num, sub.check, sub.icono from subcategoria sub, informacion i where i.idSubCat=sub.idSubCategoria and i.ciu=$ciu group by sub.idSubCategoria,sub.dessubcategoria, sub.dessubcategoria_en,sub.idcategoria, sub.check, sub.icono order by sub.idSubCategoria) sub, categoria cat where cat.idcategoria=sub.idcategoria order by cat.descategoria, sub.dessubcategoria "; $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['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['num'] = $row['num']; $query_results['check'] = $row['check']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } function findAll2() { $results = array(); // Load the db library $ciu=$this->ubica->ciu; //ciu=$ciu $this->load->database(); $sql=" select cat.idcategoria,cat.descategoria, cat.descategoria_en, sub.idsubcategoria, sub.dessubcategoria,sub.dessubcategoria_en, num, sub.icono from( select sub.idSubCategoria,sub.dessubcategoria,sub.dessubcategoria_en,sub.idcategoria, count(i) as num, sub.icono from subcategoria sub left join informacion i on (i.idSubCat=sub.idSubCategoria and i.ciu=$ciu ) group by sub.idSubCategoria,sub.dessubcategoria, sub.dessubcategoria_en,sub.idcategoria, sub.icono order by sub.idSubCategoria) sub, categoria cat where cat.idcategoria=sub.idcategoria order by cat.descategoria, sub.dessubcategoria "; $query = $this->db->query($sql); if ($query->num_rows() > 0) { 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['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['num'] = $row['num']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } function findLegend() { $results = array(); // Load the db library $this->load->database(); $sql="select cat.idCategoria as idCategoria, descategoria, descategoria_en, idSubCategoria, desSubCategoria,dessubcategoria_en, sub.check, sub.icono from categoria cat, subcategoria sub where cat.idcategoria=sub.idcategoria and cat.ver='1' and sub.ver='1' order by cat.idcategoria, sub.desSubCategoria "; $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['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['check'] = $row['check']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } function _init_Relsubcat() { } function _emptyRelsubcat() { } function byIdSubCat($idSubCat){ $results = array(); // Load the db library $this->load->database(); $ciu=$this->ubica->ciu; //ciu=$ciu $query = $this->db->query(" select cat.idcategoria,cat.descategoria, cat.descategoria_en, sub.idsubcategoria, sub.dessubcategoria,sub.dessubcategoria_en, num, sub.icono from( select sub.idSubCategoria,sub.dessubcategoria,sub.dessubcategoria_en,sub.idcategoria, count(i) as num, sub.icono from subcategoria sub left join informacion i on ( i.idSubCat=sub.idSubCategoria and i.ciu=$ciu ) group by sub.idSubCategoria,sub.dessubcategoria, sub.dessubcategoria_en,sub.idcategoria, sub.icono order by sub.idSubCategoria) sub, categoria cat where cat.idcategoria=sub.idcategoria and idsubcategoria=$idSubCat order by cat.descategoria, sub.dessubcategoria LIMIT 1"); if ($query->num_rows() > 0) { $row = $query->row_array(); $query_results['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['icono'] = $row['icono']; $query_results['num'] = $row['num']; $results = $query_results; } else { $results = false; } return $results; } function byIdCat($idCat){ $results = array(); // Load the db library $this->load->database(); $ciu=$this->ubica->ciu; //ciu=$ciu $query = $this->db->query("select cat.idcategoria,cat.descategoria, cat.descategoria_en, sub.idsubcategoria, sub.dessubcategoria,sub.dessubcategoria_en, num, sub.icono from( select sub.idSubCategoria,sub.dessubcategoria,sub.dessubcategoria_en,sub.idcategoria, count(i) as num, sub.icono from subcategoria sub left join informacion i on (i.idSubCat=sub.idSubCategoria and i.ciu=$ciu) group by sub.idSubCategoria,sub.dessubcategoria, sub.dessubcategoria_en,sub.idcategoria, sub.icono order by sub.idSubCategoria) sub, categoria cat where cat.idcategoria=sub.idcategoria and cat.idcategoria=$idCat order by cat.descategoria, sub.dessubcategoria "); if ($query->num_rows() > 0) { 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['idcategoria'] = $row['idcategoria']; $query_results['descategoria'] = $row['descategoria']; $query_results['descategoria_en'] = $row['descategoria_en']; $query_results['idsubcategoria'] = $row['idsubcategoria']; $query_results['dessubcategoria'] = $row['dessubcategoria']; $query_results['dessubcategoria_en'] = $row['dessubcategoria_en']; $query_results['num'] = $row['num']; $query_results['icono'] = $row['icono']; $results[] = $query_results; } } return $results; } } ?>