• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use multi extend Model

#1
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?
Reply

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

#3
(08-30-2017, 05: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
Reply

#4
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
{
    [...]
}

[...] 
Reply

#5
(08-30-2017, 03: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
}
Reply

#6
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.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#7
Thanks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.