CodeIgniter Forums
Use multi extend Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Use multi extend Model (/showthread.php?tid=68818)



Use multi extend Model - omid_student - 08-30-2017

Hello
I can extend my favorite Model with use My_Model in core folder
But i can use one model only,while i need model for each section of my project
Example
core/My_Model
core/User_Model
core/Galelry_Model

Maybe?


RE: Use multi extend Model - Kaosweaver - 08-30-2017

You can do it this way:
core/My_model
core/My_user_model
core/My_gallery_model


RE: Use multi extend Model - omid_student - 08-30-2017

(08-30-2017, 04:55 AM)Kaosweaver Wrote: You can do it this way:
core/My_model
core/My_user_model
core/My_gallery_model

I use it but it show error that this model not found


RE: Use multi extend Model - bvrignaud - 08-30-2017

Hi,

I use only one file : MY_Model.php and inside I have all the main model I want :
PHP Code:
class MY_Model extends CI_Model
{
    protected 
$table;
    protected 
$primaryKey;
    [...]
}

class 
MY_Other_model extends MY_Model
{
    [...]
}

[...] 



RE: Use multi extend Model - sayd - 08-30-2017

(08-30-2017, 02:29 AM)omid_student Wrote: Hello
I can extend my favorite Model with use My_Model in core folder
But i can use one model only,while i need model for each section of my project
Example
core/My_Model
core/User_Model
core/Galelry_Model

Maybe?

All you have to do is add your new models in model folder and extends MY_Model instead of CI_Model   no need to put new model in core folder 

Code:
class User extends MY_model
{
$table =YOUR_TABLE
}



RE: Use multi extend Model - InsiteFX - 08-31-2017

Rule of CodeIgniter:

CodeIgniter ./system/core go into ./application/core
CodeIgniter ./system/libraries go into ./application/libraries

--------------------------------------------------------------

So in your case MY_Model goes into ./application/core

Your models extended from the MY_Model:
Go into the ./application/models

Hope that helps.


RE: Use multi extend Model - omid_student - 09-05-2017

Thanks