⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

group by



Sazer Sazer
  • profile picture
  • Member

Posted 02 February 2015 - 22:31 PM

en el archivo system/database/DB_query_builder.php en la funcion count_all_results

cambiar

$row = $result->row();
 return (int) $row->numrows;

por

$row = $result->row();
 if(!$this->qb_groupby)return (int) $result->num_rows();
 return (int) $row->numrows;

en el archivo application/models/grocery_crud_model.php agregar la funcion

    function group_by($by='',$escape=null){
     $this->db->group_by($by,$escape);
    }

y en el archivo application/libraries/Grocery_CRUD.php en la clase

class grocery_CRUD_Model_Driver extends grocery_CRUD_Field_Types

el la funcion protected function get_total_results agregar

  if(!empty($this->group_by))
   $this->basic_model->group_by($this->group_by[0],$this->group_by[1]);

y en la funcion protected function get_list  agregar tambien

  if(!empty($this->group_by))
   $this->basic_model->group_by($this->group_by[0],$this->group_by[1]);

y en la clase class Grocery_CRUD extends grocery_CRUD_States

agregar

protected $group_by 			= null;

y agregar la funcion

public function group_by($group_by, $escape=null)
	{
		$this->group_by = array($group_by,$escape);

		return $this;
	}

y finalmente en application/models/grocery_crud_model.php

    function group_by($by='',$escape=null){

      $this->db->group_by($by,$escape);

    }

y poder usar

$crud->group_by('columna');