Home
Forums
Members
Search
Help
New topics
Todays topics
Website
Welcome Guest, Not a member yet?
Register
Sign In
Login
Username:
Password:
Remember me
Lost Password?
CodeIgniter Forums
Using CodeIgniter
Model-View-Controller
A part of my models would inherits an abstract class
Share on Google
Share on Facebook
Share on Twitter
View a Printable Version
Subscribe to this thread
Add Poll to this thread
Send thread to a friend
Linear Mode
Threaded Mode
A part of my models would inherits an abstract class
nico
Newbie
Posts:
8
Threads:
5
Joined:
Jan 2017
Reputation:
0
#1
01-16-2020, 02:56 AM
Salut !
I want re-use same code for a group of model. Is it possible to make some models inherits a class and how to do this ?
In advance, thank you.
Reply
jreklund
Administrator
Posts:
1,408
Threads:
3
Joined:
Aug 2017
Reputation:
42
#2
01-16-2020, 11:51 AM
Yes, make a base model and extend it.
models/Auth_model.php
class Auth_model extends MY_Model
core/MY_Model.php
class MY_Model extends CI_Model
Reply
nico
Newbie
Posts:
8
Threads:
5
Joined:
Jan 2017
Reputation:
0
#3
01-16-2020, 01:31 PM
Thank you, but can we make few models class in core/ ?
Reply
jreklund
Administrator
Posts:
1,408
Threads:
3
Joined:
Aug 2017
Reputation:
42
#4
01-17-2020, 11:23 AM
You can make as many you want.
But then I would place them in /models/ instead. As it's not going to be extended by all your models.
Reply
--------------------
Private Messages
User Control Panel
Who's Online
Search
Forum Home
General
-- News & Discussion
-- Events
-- Lounge
-- Regional User Groups
Using CodeIgniter
-- Installation & Setup
-- Model-View-Controller
-- Libraries & Helpers
-- Best Practices
-- Choosing CodeIgniter
-- General Help
CodeIgniter 4
-- CodeIgniter 4 Roadmap
-- CodeIgniter 4 Development
-- CodeIgniter 4 Feature Requests
-- CodeIgniter 4 Support
-- CodeIgniter 4 Discussion
-- CodeIgniter 4 Addins
Development
-- CodeIgniter 3.x
-- CodeIgniter 2.x
-- Issues
-- NetBeans Plugin
External Resources
-- Spotlight
-- Learn More
-- Jobs
-- Addins
Archived Discussions
-- Archived Libraries & Helpers
-- Archived Development & Programming
Theme © iAndrew 2016 -
Forum software by © MyBB