1

I have the following model: class_user nammed after a table in my database clas_user. When I call this model with the following code:

$class_user = new Model_Class_User();

It can't find my model. Within my model file, the class is named exactly the same way (Model_Class_User).

Does Kohana not like model names with underscores?

Prusprus
  • 7,987
  • 9
  • 42
  • 57

1 Answers1

3

Underscores directly reflect the file location in your app. Meaning your Class_User model file should be located in application/classes/model/class/user.php

The file name should not have an underscore in it.

Here are some links to learn about Kohana conventions and the cascading file system. http://kohanaframework.org/3.2/guide/kohana/conventions
http://kohanaframework.org/3.2/guide/kohana/files

Also look at http://kohanaframework.org/3.2/guide/orm/models to learn about ORM. You'll notice right away that you'll need to create a $_table_name variable because your table has an unconventional name. Example provided below.

class Model_Class_User extends ORM {
    protected $_table_name = 'class_user';
}
matino
  • 17,199
  • 8
  • 49
  • 58
  • totally agree, makes sense now. Thanks a bunch. – Prusprus Apr 08 '12 at 05:43
  • does it worked? i have a table named product_details then i made a Model_Product_Detail then i declared protected $_table_name = 'product_detail'; but it still didnt worked. – Alex Coroza Sep 07 '14 at 12:07