Welcome Guest, Not a member yet? Register   Sign In
extend Model class
#1

[eluser]adwin[/eluser]
Hi, i want to extend model class ... let call it extModel because I need to add some functionality that I use for all my models.

Where should I put my new class ?
#2

[eluser]FrankieShakes[/eluser]
[quote author="adwin" date="1210312535"]Hi, i want to extend model class ... let call it extModel because I need to add some functionality that I use for all my models.

Where should I put my new class ?[/quote]

adwin,

Why not create a Base_Model class that extends "Model"... and which all your models then extend:

1) Base_Model extends Model
2) My_Model extends Base_Model

You can then simply drop the Base_Model into the /Application/models directory and continue along as your normally would.
#3

[eluser]wiredesignz[/eluser]
MY_ is a reserved name and is used specifically for core extensions, in fact MY_Model would be the base model and will be automatically loaded by CI if it is placed in application/libraries, this is the class where you should place your global Model extensions.

MY_Model extends Model

All_other_models extend MY_Model
#4

[eluser]FrankieShakes[/eluser]
[quote author="wiredesignz" date="1210319610"]MY_ is a reserved name in CI used for core extensions, in fact MY_Model would be the base model and will be automatically loaded by CI if it is placed in application/libraries, this is the class where you should place your global Model extensions.

MY_Model extends Model

All_other_models extend MY_Model[/quote]

Hehehe... I totally forgot about the "MY" prefix. As I was writing my response, I was thinking of a quick and easy name for a model. For some reason "My_Model" came to mind, although it wasn't intended to imply the overriding of the default Model class.

1) Base_Model extends Model
2) Custom_Model extends Base_Model
#5

[eluser]wiredesignz[/eluser]
MY_Model located in application/libraries is still a better choice for global Model extensions as it is automatically loaded and becomes part of the core.
#6

[eluser]adwin[/eluser]
okay . thank you .. I will try at my application.
Thank you all ..




Theme © iAndrew 2016 - Forum software by © MyBB