Search code examples
phpkohanakohana-3kohana-ormkohana-3.2

kohana 3.2 creating a model for a table with underscore in its name


I am having trouble in creating a model for a table named product_details, and after searching sometimes, I found this answer

Kohana 3.2: Calling model with underscore in name

acoording on the answer, I resorted to the following approach. I created Model_Product_Details then i declared protected $_table_name = 'product_details'; and then saved it in application/classes/models/product_detail.php

And the I called it in a controller with this code:

$product_details = ORM::factory(product_detail);

But damn, it didnt work. the error returned was ErrorException [ Fatal Error ]: Class 'Model_Product_detail' not found

I tried renaming the table, model and file name by removing the underscore and it worked. But the thing is the database im using is from legacy system so i cant change its name. I hope could give me help immediately.


Solution

  • After analyzing the answer on the link I provided for the third time(I think), referring the approach I've done, I just have to remove the underscore from the file name and the model name only.

    So this is the way how to fix it. Lets say you have a table named product_details. You have to create Model_ProductDetail then in the inside, declare protected $_table_name = 'product_details'; then save it as productDetail.php