⚠ 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

Distinct records



JustMe
  • profile picture
  • Member

Posted 07 March 2013 - 19:04 PM

How does one access the CI distinct method from GC?

I tried adding in a new function into GC but I get error that it cannot find?

 

Any suggestions?

 

Thanks

 


davidoster
  • profile picture
  • Member

Posted 07 March 2013 - 23:03 PM

You need to extend the default Grocery CRUD model and there make any custom database handling.

View here for more information: http://www.grocerycrud.com/documentation/options_functions/set_model


JustMe
  • profile picture
  • Member

Posted 07 March 2013 - 23:59 PM

Thanks.. I will take a look .. 

 

Brian


JustMe
  • profile picture
  • Member

Posted 08 March 2013 - 00:39 AM

Any suggestions? -Thanks

 

Here is the error message I get.

 

Fatal error: Call to undefined method grocery_CRUD::distinct() in /CodeIgniter_2.1.3/application/controllers/examples.php on line 94

 

 

Here is my set up for application/controllers/examples.php

 

 

   function class_grade_profile_management()
        {
                        $crud = new grocery_CRUD();
 
$crud->set_model('MY_grocery_Model');
$crud->distinct();
 
<Snip Snip the rest>
 
        }
 

 

Here is my my_grocery_model.php

 

<?php
 
class MY_grocery_Model  extends grocery_CRUD_Model {
 
 
 
    function distinct()
 
    {
 
        $this->db->distinct();
    }  
 
 
}

davidoster
  • profile picture
  • Member

Posted 08 March 2013 - 10:47 AM

This is how you call the model's functions,

 

//extract from a project of mine

 

$this->load->model('itemmodel');
$activities = $this->itemmodel->get_activities("activities");
 
amend your code to match the way you have it,
 
$crud->yourmodel->distinct()

JustMe
  • profile picture
  • Member

Posted 08 March 2013 - 22:22 PM

Thanks for the help. But I still cannot get it to work.

Brian