Welcome Guest, Not a member yet? Register   Sign In
Model in multiple applications
#1

[eluser]Nowakis[/eluser]
Hi,

How best to share the models for two applications?
I am using the following structure:

Code:
/application/
    /frontend/
        /models/model1.php
        /models/model2.php
    /backend/
        /models/model1.php
        /models/model2.php
/system/
index.php
#2

[eluser]Phil Sturgeon[/eluser]
Well without "hackery" it would be impossible. However in one model you can do this to include the other:

Code:
include(BASEPATH.'backend/models/model2.php');
$model = Model2();

$model->get(10);

But why are you separating your front and back ends if you need to share code? There are much better methods for user/admin separation. Take a look at the post: Website and admin structure. You are using method 1. Method 2 or 3 will allow model sharing with more "CI-like" syntax.
#3

[eluser]umefarooq[/eluser]
i have question from pyromaniac can i use common model as library for my application to manipulate the database. if every model have same functions to call every time we can create just a single library, we will just pass the parameters to that library functions. and it is also easy to modify only one place will effect the whole application, no need to modify each and every model.
#4

[eluser]Phil Sturgeon[/eluser]
Not sure I understand the question (language barrier I think), but models and libraries are pretty much the same ting with a different purpose. They are both just classes, but models should be used for data manipulation and libraries for storing advanced logic and other crazy stuff.




Theme © iAndrew 2016 - Forum software by © MyBB