⚠ 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

How to use set_model function ?



hogogo
  • profile picture
  • Member

Posted 18 July 2012 - 15:08 PM

Dear all

I'm newbies to CodeIgniter and Grocery CRUD.
Thanks for GroceryCRUD's author, John Skoumbourdis.
This project make my life more easy and more relax :)

I wanna use set_model function which handle some work

set_model is used in my code (Controller's method):

$crud->set_model('My_model');


and then, created my_model.php file in application/model folder

class My_model extends grocery_CRUD_Model {
function list_all(){
$this->db->order_by('sn','desc');
return $this->db->get("table1");
}
}


But now, how can I use My_model's method list_all in Grocery CRUD code ?
Because I used the code:

$this->My_model->list_all();

Nothing happen :(

and used this code:

$crud = new grocery_CRUD();
$crud->My_model->list_all();

Show me error message:
Message: Undefined property: grocery_CRUD::$My_model :(

Today, I searched all day in this topic, but I can't found any about this topic
Thanks for anybody who can help me :)

And my English text is a little weak, please don't mind. :)

fdias
  • profile picture
  • Member

Posted 20 July 2012 - 16:57 PM

Check this post as I believe will help you:

/topic/90-how-to-create-an-extension-for-grocery-crud-real-example-included/

Cheers.